Samza Posted May 2, 2013 Share Posted May 2, 2013 Hey, I am getting 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 '' at line 1 and the mysql_query is; $sql = mysql_query("INSERT INTO shopping_cart (cart_identifier, product_id, product_title, product_qty, product_price, sdate) VALUES ('". mysql_real_escape_string($_SESSION['cid']) . "', '$product_id', '{$products['product_title']}', '$product_qty', '{$products[product_price]}', '$sdate'") or die (mysql_error()); I have exhausted every optional my knowledge can devise! Thanks for your help, Sam Quote Link to comment Share on other sites More sharing options...
akphidelt2007 Posted May 2, 2013 Share Posted May 2, 2013 Whenever you have query problems like this... echo out the query for debugging... I'm willing to bet you will see what your problem is. One of the values might be containing a character that is breaking the query. echo "INSERT INTO shopping_cart (cart_identifier, product_id, product_title, product_qty, product_price, sdate) VALUES ('". mysql_real_escape_string($_SESSION['cid']) . "', '$product_id', '{$products['product_title']}', '$product_qty', '{$products[product_price]}', '$sdate'")"; Quote Link to comment Share on other sites More sharing options...
Samza Posted May 2, 2013 Author Share Posted May 2, 2013 I echoed it out and I can't see what is wrong, everything seems to be perfect INSERT INTO shopping_cart (cart_identifier, product_id, product_title, product_qty, product_price, sdate) VALUES ('b221125f5badb81dd17ea21e38453328', '1', 'PHP Baseball Hat', '1', '12.95', '2013-05-02 15:26:35' Quote Link to comment Share on other sites More sharing options...
Solution akphidelt2007 Posted May 2, 2013 Solution Share Posted May 2, 2013 (edited) Oh, now I see it. You notice the ) isn't showing up at the end of the string? Add the closing parentheses to the VALUES part of the query and it should work. Edited May 2, 2013 by akphidelt2007 Quote Link to comment Share on other sites More sharing options...
Samza Posted May 2, 2013 Author Share Posted May 2, 2013 Oh yes ! Got it finally! Thanks so much ! Finally I can move on with my life Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.