Jump to content

SQL Error?


Paws

Recommended Posts

Hey, I am having trouble with the following sql query...

 

$query = mysql_query("INSERT INTO `orders` (`order_status`,`productcode` ,`dispatch_date` ,`customer_id`) VALUES ('Ordered', '$item', '$date', '$email'") or trigger_error(mysql_error());

 

I am getting the error...

 

Notice: 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 in /home/spadean1/public_html/john/order.php on line 46

 

Any help appreciated.

 

Thanks

Link to comment
Share on other sites

You should get in the habit of creating your query as a string variable. Then when there is a problem you can echo the query to the page or log it somewhere so you can debug the error. It is not always apparent what the error is when looking at how the query is built. It is much more apparent when looking at the final code of the query. Like this:

 

$query = "INSERT INTO `orders`
          (`order_status`, `productcode`, `dispatch_date`, `customer_id`)
          VALUES ('Ordered', '$item', '$date', '$email')";
$result = mysql_query($query) or trigger_error("Query:<br />$query<br />Error:<br />".mysql_error());

Link to comment
Share on other sites

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.