Jump to content

[SOLVED] Error in your SQL syntax


ayok

Recommended Posts

Hi,

I've been trying to insert some datas into mysql problems with this code:

<?php
$enter="INSERT INTO order(prod_id,quantity,subtotal) VALUES('$ses_id','$ses_quan','$subtotal')";
$input=mysql_query($enter) or die(mysql_error()); ?>

But i keep getting this error msg:

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 'order(prod_id,quantity,subtotal) VALUES('29','4','136')' at line 1

 

Would anybody tell me where the mistakes?

 

Thank you

ayok

Link to comment
Share on other sites

order is a reserved word - http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

 

You should change the name of the table to avoid future problems. You can enclose it in back-ticks `order` but that is a mysql specific usage and won't work if you ever move your code to a different sql database or msyql changes to more closely follow standards in the future.

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.