zdyn
zdyn

Reputation: 2183

Limiting characters in textarea - escaped quotes and double quotes take up 2 characters in MySQL

I want to limit a textarea to a certain number of characters and have written a JavaScript function to notify the user of the remaining number of characters. This limit matches the limit set in MySQL for that particular field.

However, when saving the contents using PHP and mysql_real_escape_string(), it saves quotes and double quotes (and I'd imagine backslashes and all other escaped stuff) with a backslash so that those characters actually take up 2 spaces, thus rendering the JS function inaccurate. Any thoughts on how to get around this?

EDIT: Per deceze's advice I checked if magic quotes were on and they are using a check with get_magic_quotes_gpc().

But I have also checked the directory's .htaccess file and found this flag:

php_value magic_quotes_gpc                0

Which is apparently not turning off magic quotes. Any idea why?

Upvotes: 0

Views: 1191

Answers (1)

deceze
deceze

Reputation: 522461

If it's saving extraneous slashes, it's not actually saving the text you want to save.
It sounds like you have magic quotes enabled. Disable them.

Upvotes: 1

Related Questions