Jump to content

sql error on Multi-page Order script (using session).


Recommended Posts

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);
?>

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']);

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.

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.