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
https://forums.phpfreaks.com/topic/83699-solved-error-in-your-sql-syntax/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.