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?
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.
精彩评论