cturner Posted November 6, 2006 Share Posted November 6, 2006 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 heremysql_close();[/code] Link to comment https://forums.phpfreaks.com/topic/26285-could-not-add-the-entry-because/ Share on other sites More sharing options...
akitchin Posted November 6, 2006 Share Posted November 6, 2006 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. Link to comment https://forums.phpfreaks.com/topic/26285-could-not-add-the-entry-because/#findComment-120203 Share on other sites More sharing options...
cturner Posted November 6, 2006 Author Share Posted November 6, 2006 I have been at my computer too long. Thanks akitchin. You solved it. Link to comment https://forums.phpfreaks.com/topic/26285-could-not-add-the-entry-because/#findComment-120212 Share on other sites More sharing options...
fenway Posted November 6, 2006 Share Posted November 6, 2006 Also, you really shouldn't be explicitly passing a '0' to the auto-increment field. Link to comment https://forums.phpfreaks.com/topic/26285-could-not-add-the-entry-because/#findComment-120443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.