Click to See Complete Forum and Search --> : Frustrating double quote problem
DrMarie
06-30-2009, 08:45 PM
I have a problem with things disappearing from my mysql database. It seems to happen when double quotes are used. I am using mysql_real_escape_string($variable) to insert the string into the database.
The problem seems to come when I read the string from the database, modify it and then put back in. It goes through a mysql_real_escape_string($variable) when it goes back in as well.
Any ideas?
DrMarie
07-01-2009, 12:55 PM
After about 10 hours of debugging I finally found the problem! I thought I would post it here in case it helps anyone else.
What I was doing was reading some database info and then passing it to another page via a POST form and then manipulating it and reinserting it into the database.
The problem was not with the mysql_real_escape_string but instead was in the POST. For some reason if a variable containing double quotes was sent it would truncate. So if I sent : This is a "test"
it would come across the post as This is a
How I solved it was just to send the $id variable across the POST and then reopen the database and take the data directly from there.
Hope that helps someone!
How frustrating!
Dasher
07-01-2009, 04:46 PM
What I do;
Data going from input form to post (no problem with $_POST)
before database
$mytext = htmlspecialchars(mysql_real_escape_string(stripslashes(strip_tags ($_POST[mytext'],'<a><b><br><i><p><s><strong><ul><li>'))),ENT_QUOTES);
And coming from database
$text = htmlspecialchars_decode($a_row[7],ENT_QUOTES);
Pembar
07-02-2009, 06:05 AM
$mytext = htmlspecialchars(mysql_real_escape_string(stripslashes(strip_tags ($_POST[mytext'],'<a><b><br><i><p><s><strong><ul><li>'))),ENT_QUOTES);
I think you missed a ' before mytext.
Dasher
07-04-2009, 12:31 AM
Oops my bad. I was changing the real column name to mytext and accidentally deleted the ' too.