Apostrophe Problems |
Apostrophe Problems |
jamesjohnson88 |
Apr 30 2009, 09:23 AM
Post
#1
|
Newbie Group: Members Posts: 16 Joined: 31-March 09 Member No.: 8,202 |
Whenever a form is submitted to my DB, if it has an apostrophe in it my MySQL throws an error. This is the code -
QUOTE $con = mysql_connect("localhost","u08105199","edited"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("u08105199", $con); // Get values to insert. $sql="INSERT INTO contactMe (FirstName, LastName, Age, Email, Comments) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]','$_POST[email]','$_POST[comments]')"; if (!mysql_query($sql,$con)) //Function is called. { // IF statement to check for errors. die('Error: ' . mysql_error()); // Error checking feedback. } else { echo ("Thank you, your comment has been added."); // Feedback message. } mysql_close($con) I know I have to do something with escape strings but I just can't get my head around what parts of the code needs changing. Any help is appreciated. |
Lo-Fi Version | Time is now: 19th April 2024 - 09:35 PM |