Jump to content

[SOLVED] Addslashes


jandrews3

Recommended Posts

If I have the variable $text for a textarea, and the user enters an apostrophe ... when the form is submitted, is addslashes($text) not sufficient before updating the record in a mysql database??? I'm getting the following error: (I must be an idiot)

Could not perform update: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's classification is Human Resources. Active in the promotion of several causes,' at line 1

 

It appears that the apostrophe is closing the UPDATE request and then causing an error with the remaining text. What easy thing am I overlooking? Thanks.

Link to comment
Share on other sites

Not directly related to your error, but because addslashes() (and magic_quotes) does not escape all the special characters that can break a query (allowing a hacker to trigger an error on your server by feeding your code unexpected data), you should use mysql_real_escape_string() on any data placed into a query that could contain special characters.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.