Jump to content

Recommended Posts

For some crazy reason if any of my entries in the form fields have an Apostrophe in it, the data record is not recorded.  Any ideas on a fix?  Here is the code that deals with the database insert on my process file.

 

	  $db_host = "localhost"; $db_user = "XXX";$db_pass = "XXX";$db_name = "XXX";$db_table = "XXX";
$link = mysql_connect($db_host,$db_user,$db_pass);
if(!$link) die ('Could not connect to database: '.mysql_error());
mysql_select_db($db_name,$link);
$query = "INSERT into `XXX` (Name,Address,CityStateZip,Phone,School,SchoolAddress,Grade,Subject,Statement,Brand,Vendor,Referral,Age,Gender,Email) VALUES ('" . $_POST['Name'] . "','" . $_POST['Address'] . "','" . $_POST['CityStateZip'] . "','" . $_POST['Phone'] . "','" . $_POST['School'] . "','" . $_POST['SchoolAddress'] . "','" . $_POST['Grade'] . "','" . $_POST['Subject'] . "','" . $_POST['Statement'] . "','" . $_POST['Brand'] . "','" . $_POST['Vendor'] . "','" . $_POST['Referral'] . "','" . $_POST['Age'] . "','" . $_POST['Gender'] . "','" . $_POST['Email'] . "')";
mysql_query($query);
mysql_close($link);
    }

Link to comment
https://forums.phpfreaks.com/topic/244436-apostrophes-preventing-database-record/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.