PDA

View Full Version : Storing special characters in MySQL



jc_gmk
07-17-2007, 02: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?

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

jc_gmk
07-17-2007, 03: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?

e.g.



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

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