I can't understand what is happening to my text entry upon insertion into my database. I want to allow text entry with special characters e.g double quotes. I have magic quotes enabled.
I take the text entered ($report) and then create another variable $report1 with the quotes stripped out. $report1 is used as a preview of entry on the next page and $report passes as a hidden value. I then insert/update the database using the var $report.
I've tried displaying the var $report and it appears correctly eg. hello \"world\"
but for some reason the text entered into the database stops once it reaches a \".
What am I doing wrong? I can get the data to enter correctly when I run the SQL manually. Below is my code and finally the SQL called...
if ($submit1) { // validate and preview
if (get_magic_quotes_gpc())
{
$report1 = stripslashes($report);
}else{
$report1 = $report;
$report = addslashes($report);
}
if ($print ==0) {
$report1 = nl2br($report1);
$report = nl2br($report);
}
echo $report1; ?>
<input type="hidden" name="matchid" value="<?php echo $matchid; ?>">
<input type="hidden" name="print" value="<?php echo $print; ?>">
<input type="hidden" name="report" value="<?php echo $report; ?>"></td>
$reportedit = "UPDATE report_2001 SET reporttext = '$report' WHERE matchid=".$matchid;
$insertedit = mysql_query($reportedit);
} else {
$reportinsert = "INSERT INTO report_2001 (matchid,reporttext) VALUES ('$matchid','$report')";
$insert = mysql_query($reportinsert);
}