Jump to content

Could not add the entry because...???


cturner

Recommended Posts

I am getting the following error when I test the code that is below. I have commented out most of my code to find this error as I had other problems before this. Anyway can someone please look at the code that is below and tell me why I am getting this error? Thanks in advance.

Could not add the entry because: 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 'VALUES ('0', 'cturner', 'chloe', '6 November 2006', 'C', 'Turner', 'Blue G' at line 1. The query was INSERT INTO `tbl_users` (`userid`, `user_username`, `user_password`, `user_regdate`, `user_firstname`, `user_lastname`, `user_company`, `user_address`, `user_towncity`, `user_state`, `user_postcode`, `user_country`, `user_phone`, `user_email`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address`, `shipping_towncity`, `shipping_state`, `shipping_postcode`, `shipping_country`, `mailinglist`, `additional` VALUES ('0', 'cturner', 'chloe', '6 November 2006', 'C', 'Turner', 'Blue Gum Interactive', 'somewhere', 'else', 'nsw', 'postcode1', 'country1', '02 67555555, '[email protected]', 'C', 'Turner', 'Blue Gum Interactive', 'somewhere', 'else', 'nsw', '2222', 'aus', 'checkbox', 'n/a').

[code=php:0]
if (isset($_POST['submit'])) {
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$firstname1 = mysql_real_escape_string($_POST['firstname1']);
$lastname1 = mysql_real_escape_string($_POST['lastname1']);
$company1 = mysql_real_escape_string($_POST['company1']);
$address1 = mysql_real_escape_string($_POST['address1']);
$towncity1 = mysql_real_escape_string($_POST['towncity1']);
$state1 = mysql_real_escape_string($_POST['state1']);
$postcode1 = mysql_real_escape_string($_POST['postcode1']);
$country1 = mysql_real_escape_string($_POST['country1']);
$phone1 = mysql_real_escape_string($_POST['phone1']);
$email1 = mysql_real_escape_string($_POST['email1']);
// shipping details
$firstname2 = mysql_real_escape_string($_POST['firstname2']);
$lastname2 = mysql_real_escape_string($_POST['lastname2']);
$company2 = mysql_real_escape_string($_POST['company2']);
$address2 = mysql_real_escape_string($_POST['address2']);
$towncity2 = mysql_real_escape_string($_POST['towncity2']);
$state2 = mysql_real_escape_string($_POST['state2']);
$postcode2 = mysql_real_escape_string($_POST['postcode2']);
$country2 = mysql_real_escape_string($_POST['country2']);

$shippingmethod = mysql_real_escape_string($_POST['shippingmethod']);
$mailinglist = mysql_real_escape_string($_POST['mailinglist']);
$hearabout = mysql_real_escape_string($_POST['hearabout']);
$additional = mysql_real_escape_string($_POST['additional']);

$sql = "INSERT INTO `tbl_users` (`userid`, `user_username`, `user_password`, `user_regdate`, `user_firstname`, `user_lastname`, `user_company`, `user_address`, `user_towncity`, `user_state`, `user_postcode`, `user_country`, `user_phone`, `user_email`, `shipping_firstname`, `shipping_lastname`, `shipping_company`, `shipping_address`, `shipping_towncity`, `shipping_state`, `shipping_postcode`, `shipping_country`, `mailinglist`, `additional` VALUES ('0', '$username', '$password', '$date2', '$firstname1', '$lastname1', '$company1', '$address1', '$towncity1', '$state1', 'postcode1', 'country1', '$phone1, '$email1', '$firstname2', '$lastname2', '$company2', '$address2', '$towncity2', '$state2', '$postcode2', '$country2', '$mailinglist', '$additional')";
}
// more code here
mysql_close();
[/code]
Link to comment
https://forums.phpfreaks.com/topic/26285-could-not-add-the-entry-because/
Share on other sites

with all due respect, how can it not be totally obvious that you're missing a closing parenthesis in your query?  look before VALUES:  anything seem to be missing there?  the error often tells you exactly where MySQL choked, as it does here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.