How to insert special characters into a database? How to insert special characters into a database? database database

How to insert special characters into a database?


$insert_data = mysql_real_escape_string($input_data);

Assuming that you have the data stored as $input_data


Are you escaping? Try the mysql_real_escape_string() function and it will handle the special characters.


You are most likely escaping the SQL string, similar to:

SELECT * FROM `table` WHERE `column` = 'Here's a syntax error!'

You need to escape quotes, like follows:

SELECT * FROM `table` WHERE `column` = 'Here\'s a syntax error!'

mysql_real_escape_string() handles this for you.