&(ampersand) character is not inserting database
When i 开发者_如何学JAVAam inserting value from textarea my sql query is not inserting data after '&' character.before '&' all character is being update in database.I am using mysql_real_escape_string()
function.
What is should to for these special character ?
No, nothing to do with this character.
But you definitely have to debug your code to see what happened to your data.
By tracing it on the whole path from textarea to database.
Most likely it doesn't even present in the query. You have least to print this query and check if it's all right. If no - trace back. Print textarea data in the various places of your script to catch the place where ampersand is lost.
Probabaly worth making sure you're enclosing the string in quotes. Otherwise we're going to need more detail!
Wrong:
UPDATE table SET value = & WHERE field = 'foo'
Right:
UPDATE table SET value = '&' WHERE field = 'foo'
Do you also have magic quotes enabled in your php.ini? That can lead to some gotchas.
You can check it by running this code in a new page.
if(get_magic_quotes_gpc())
echo "Magic quotes are enabled";
else
echo "Magic quotes are disabled";
If you have magic quotes enabled, and you try to mysql_real_escape_string, you can double-escape things. Other things to check: Is the text too long to put into the appropriate column? MySQL truncates data to fit instead of throwing an error that its too big.
精彩评论