I have a testimonial page where the user can write a testimonial for me.
I get this error message if the user use a single quote mark.
example:
Demonstrated professionalism and creativity as the company's web and marketing materials designer.
Will produce this error;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's web and marketing materials designer. ')' at line 1
here is my code for the php:
HTML code
my db for the comment is
comments text should I use varchar instead?
Any help would be great.
damon
I get this error message if the user use a single quote mark.
example:
Demonstrated professionalism and creativity as the company's web and marketing materials designer.
Will produce this error;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's web and marketing materials designer. ')' at line 1
here is my code for the php:
Code:
//check for required fields from the form
if ((!$_POST[company]) || (!$_POST[fname]) || (!$_POST[comments])) {
header("Location: addtestimonial.html");
exit;
}
//connect to server and select database
bab bab bab...
//create and issue the first query
$add_testimo = "insert into testimo values ('', '$_POST[company]', now(), '$_POST[fname]', '$_POST[comments]') ";
mysql_query($add_testimo,$conn) or die(mysql_error());
//get the id of the last query
$testimo_id = mysql_insert_id();
//create nice message for user
$display_block = "<P>The <strong>$topic_title</strong> testimonial has been created. <br>
You wrote: <br>
$_POST[comments], <br>
$_POST[company], <br>
$_POST[fname],<P>
Thank you for your business and your time. If you need any upgrades
please ket ne know.</p>";
?>
Code:
<form method=post action="do_addtestimonial.php"> <p align="left"><strong class="maintext">Your Companies Name:</strong><br> <input type="text" name="company" size=40 maxlength=150> <p align="left"><strong class="maintext">Your First Name:</strong><br> <input type="text" name="fname" size=40 maxlength=150> <P align="left"><strong class="maintext">Your Testimonial:</strong><br> <textarea name="comments" cols=75 rows=5 wrap=virtual id="comments"></textarea> <P align="left"><input type="submit" name="submit" value="Add Testimonial"> </p> </form>
comments text should I use varchar instead?
Any help would be great.
damon
Comment