View Full Version : Storing special characters in MySQL

07-17-2007, 01:32 PM
I need to store special characters in a MySQL database e.g. "

If I then call that field using PHP everything after the " is missing.

I've tried entering a backslash e.g. \" straight into the database but when calling that it just displays \\

Do i need to use a PHP function to make this work or do I need to edit the database directly?

Any Ideas?

07-17-2007, 01:50 PM
Use mysql_real_escape_string() to convert the string to one safe to use in a MySQL query.

07-17-2007, 02:27 PM
The special characters are already stored in the database; the problem comes when calling them, do I still need that function? If so where would I place it in this example?


while($info = mysql_fetch_array( $result ))
print $info['row'];

07-17-2007, 02:48 PM
Oh, I see, try stripslashes() instead. Sounds like magic quotes.