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
https://forums.phpfreaks.com/topic/122158-solved-addslashes/
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
https://forums.phpfreaks.com/topic/122158-solved-addslashes/#findComment-630690
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.