Namtip Posted August 23, 2010 Share Posted August 23, 2010 SET UP: Windows vista # XAMPP 1.7.3, # Apache 2.2.14 (IPv6 enabled) + OpenSSL 0.9.8l # MySQL 5.1.41 + PBXT engine # PHP 5.3.1 # phpMyAdmin So I'm getting this error message: 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 8. I can't see where the '", )' code is in that script. I've looked and contrl + find it but no joy. I've looked through the previous pages and mysql database to ensure the variables and the tables match up. Any help would be appreciated. Maybe some good mysql debug advice. Is there a good debug open source program out there? Any help would be appreciated. :'( <?php //let's start our session, so we have access to stored data session_start(); include 'db.inc.php'; $db = mysql_connect('localhost', 'root', '') or die ('Unable to connect. Check your connection parameters.'); mysql_select_db('ourgallery', $db) or die(mysql_error($db)); //let's create the query $query = sprintf("INSERT INTO subscriptions ( name, email_address, membership_type, terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_data) VALUES ('%s','%s','%s','%s','%s','%s','%s')", $_SESSION['email_address'], $_SESSION['membership_type'], $_SESSION['terms_and_conditions'], $_POST['name_on_card'], $_POST['credit_card_number'], $_POST['credit_card_expiration_data']); //let's run the query mysql_query($insert_query); ?> Quote Link to comment https://forums.phpfreaks.com/topic/211464-sql-error-on-multi-page-order-script-using-session/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2010 Share Posted August 23, 2010 You should probably echo the $query variable so that you can see exactly what is in it. Quote Link to comment https://forums.phpfreaks.com/topic/211464-sql-error-on-multi-page-order-script-using-session/#findComment-1102555 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 also turn on error reporting as your sprintf will fail you accept 7 parameters and only pass 6 your missing name //let's create the query $query = sprintf("INSERT INTO subscriptions ( name, email_address, membership_type, terms_and_conditions, name_on_card, credit_card_number, credit_card_expiration_data) VALUES ('%s','%s','%s','%s','%s','%s','%s')", $_SESSION['name'], ///<-----MAYBE ??? $_SESSION['email_address'], $_SESSION['membership_type'], $_SESSION['terms_and_conditions'], $_POST['name_on_card'], $_POST['credit_card_number'], $_POST['credit_card_expiration_data']); Quote Link to comment https://forums.phpfreaks.com/topic/211464-sql-error-on-multi-page-order-script-using-session/#findComment-1102569 Share on other sites More sharing options...
Namtip Posted August 23, 2010 Author Share Posted August 23, 2010 PFMaBiSmAd, thanks. I did that and worked out the error by myself . It turned out that it was exactly what mad techie said (I really did figure it out before I read his post)! It's fixed! I have a multi-page script that inserts information into a database. Watch out facebook! Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/211464-sql-error-on-multi-page-order-script-using-session/#findComment-1102572 Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2010 Share Posted August 23, 2010 That's pretty wild because in the thread where that code was first posted for you it had a variable for each value in the query. Quote Link to comment https://forums.phpfreaks.com/topic/211464-sql-error-on-multi-page-order-script-using-session/#findComment-1102573 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.