Forum Moderators: coopster

Message Too Old, No Replies

Getting rid of the slashes

         

Musicarl

8:16 pm on Oct 24, 2005 (gmt 0)

10+ Year Member



Hello.

We moved our site to PHP, and for a while we had our addslash setting so that any quotes were displaying with \\\. As a result, we have a database full of text containing \\\. Is there a query we can run on our MySQL database that will eliminate these addslashes? Since the addslash is an escape character, I'm not sure how to do it.

skinter

12:16 am on Oct 25, 2005 (gmt 0)

10+ Year Member



I'm not sure if this will help you or not, but I believe PHP has a stripslashes function. I'm not sure if it can do what you want it to, but it's worth a shot.

More information can be read at: [us2.php.net...]

Netter

9:52 am on Oct 26, 2005 (gmt 0)

10+ Year Member



mysql query:
update table1 set field1=replace(field1,'\', '') where date=....

just don't forget to specify the region of lines to be affected in WHERE because otherwise you may remove slashes for some old data as well.

one sting that does all the replacements needed.

ps: it will remove all slashes (\). in 95% this solution is ok, just don't forget about specifying rown in WHERE

soflution

8:19 pm on Oct 26, 2005 (gmt 0)

10+ Year Member



Check your php.ini and ensure magic_quote gpc is set to Off. This will avoid unexpected addition or removal of slashes. Escape content with mysql_real_escape_string() before inserting it to MySQL and it will come out just as you want it, with no added /