Single quote php problem

The issue: when you write a single quote (‘) into a html input, textarea etc, the php file that is processing the form won’t insert the data into your SQL database.


Solution: add “mysql_real_escape_string” before your input variable.

Example: $_POST[‘description’] > becomes mysql_real_escape_string($_POST[‘description’]);

You get an error if you use mysql_real_escape_string if you don’t have a sql connection above it. Something like config.php, some lines of code that is connecting you to your sql database.

If you have comments, please leave in the comments.