I have a script that lets me replace values in my database.
When I use this:
$search[] = ("\\");
$sql[$handle]['sql'] = 'UPDATE '.$table.' SET '.$field.' = REPLACE('.$field.',\''.$search[$i].'\',\''.$replace[$i].'\')';
I get the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”\’)’ at line 1)
I understand its probably just a question of escaping the backslash but Ive tried everything (changing to doublequotes, escaping, using character codes, utf 8 encode/decode etc and still no luck.
Notice that the other values work well (I have a list of $search[] values)
Because
"\\"creates string\, therefore plain SQL isREPLACE('...,\'), which is an error. Use:Take a look at mysql string literals.