Joey Morani Joey Morani - 4 months ago 51
MySQL Question

How to insert special characters into a database?

Can anyone tell me how to insert special characters into a MySQL database? I've made a PHP script which is meant to insert some words into a database, although if the word contains a ' then it wont be inserted.

I can insert the special characters fine when using PHPmyAdmin, but it just doesn't work when inserting them via PHP. Could it be that PHP is changing the special characters into something else? If so, is there a way to make them insert properly?

Answer
$insert_data = mysql_real_escape_string($input_data);

Assuming that you have the data stored as $input_data

Comments