Shekhar Chatterjee Shekhar Chatterjee - 3 months ago 9x
MySQL Question

Repair double slash in Image Url

Whenever I try fetching Image Url from database, all single slash convert into double slash while viewing in browser. Here I have listed both correct URL and displayed URL.

Correct URL:

Displayed URL:

Although I know how to use PREG MATCH to rectify this issue, however I am fetching the complete row from MySQL and converting it into JSON.


You could use stripslashes($str) within your loop to remove the backslashes. For example, if your code is looping through some data and the image URL is $data['imageURL']; you could do something like this:

            $imageURL = stripslashes($data['imageURL']);
            // DO WHATEVER YOU LIKE WITH THE $imageURL    

Hope this helps a bit....

Cheers & Good-Luck...