MySQL/PHP inserting escaped character

When you use mysql_real_escape_string to escape characters before inserting a string in a MySQL database, to avoid MySQL injection, for example or to be able to insert text like “dog’s bone”, ideally, the string inserted would not have the escape character \. The text would look like “dog’s bone” and not “dog\’s bone.

However, depending on your Linux installation, you may have this undesirable behavior. Why? Because the directive magic_quotes_gpc is set to On in your php.ini file.

So set it to Off and restart Apache.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s