php - Can''t insert into table -
the intended purpose of script add item resembles shopping cart. when user clicks button script below should load.
the script starts getting product id product name has been entered in form.
this put variable.
the insert query performed, using last_insert_id() method id of last order added
if(isset($_get['submit1'])) { $db_product_name = $_get['product_name']; $query = "select productid product product_name = '$db_product_name'"; $result = mysql_query($query) or die(mysql_error()); $fetch = mysql_fetch_assoc($result); $db_productid = $fetch['productid']; $query = "insert `the_shop`.order_line_item( `orderid` `productid` ) values ( `last_insert_id()`, `$db_productid`)"; $result = mysql_query($query) or die(mysql_error()); }
however following error:
you have error in sql syntax; check manual corresponds mysql server version right syntax use near '
productid
) values (last_insert_id()
,..
)' @ line 3
you have missed comma after orderid
insert `the_shop`.order_line_item( `orderid`, -- <---- here missed comma `productid` )
mysql points part of query cannot parse. means syntactic error occurred right before cited part
Comments
Post a Comment