0

I have been inserting some data in MYSQL with escaped quotes like this \' or \" the issue here is that mysql inserts the full sequence \' inestead of '

I cant find the solution online

thanks in advance

  • Try doing `stripslashes()` on the variable then – Mike Jun 12 '12 at 02:16
  • This is how it is supposed to work. You need to remove the slashes after you select from database using stripslashes() or str_replace(). – cen Jun 12 '12 at 02:59

1 Answers1

0

Rather than replace individual quotation marks, run the function

$cleanString = mysql_real_escape_string($incomingText);

(note, this method has been deprecated in place of the following method) or

$cleanString = mysqli_real_escape_string($incomingText); 

This will also protect you against SQL injections. After the methods been run, insert text $cleanString instead of $incomingText.

Hope this helps.

Connor Deckers
  • 2,447
  • 4
  • 26
  • 45