troblesome insert statement
Posted: Tue Oct 20, 2009 12:52 pm
hi guys,
i would really appreciate if you help me with the following problem:
i'm still getting an syntax error message (Error: 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) while executing this statement out of PHP:
INSERT INTO chezelle.products (prod_no,prod_desc_eng,prod_desc_svk,main_cat_id,sub_cat_id,color_eng,color_svk,size,material_eng,material_svk,price,in_stock,pieces_in_stock,pic_small,pic_large) VALUES('1050','dkssqpdkqpdkqpdk','dqwkdpoqkdpoqkd',1,2,'dqkdpoqkpdkqpkp','dqdkqpdkqpodkqd','dkdkapd','dqkdpqkdqp','dqkdqpdkq',15,'n',0,'thumbs/ART-NR.1030_t.jpg','ART-NR.1030.jpg')
In fact, what surprises me is that the insert statement gets executed and there is a new row in the table after the execution of the code, but i still cannot get rid of the error statement.
when i execute the same statement out of phpmyadmin it also executes without a problem.
i'm using the following code:
I enclose strings into '' and leave the numeric value unenclosed.
any ideas?
i would really appreciate if you help me with the following problem:
i'm still getting an syntax error message (Error: 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) while executing this statement out of PHP:
INSERT INTO chezelle.products (prod_no,prod_desc_eng,prod_desc_svk,main_cat_id,sub_cat_id,color_eng,color_svk,size,material_eng,material_svk,price,in_stock,pieces_in_stock,pic_small,pic_large) VALUES('1050','dkssqpdkqpdkqpdk','dqwkdpoqkdpoqkd',1,2,'dqkdpoqkpdkqpkp','dqdkqpdkqpodkqd','dkdkapd','dqkdpqkdqp','dqkdqpdkq',15,'n',0,'thumbs/ART-NR.1030_t.jpg','ART-NR.1030.jpg')
In fact, what surprises me is that the insert statement gets executed and there is a new row in the table after the execution of the code, but i still cannot get rid of the error statement.
when i execute the same statement out of phpmyadmin it also executes without a problem.
i'm using the following code:
Code: Select all
$insert_new_query = "INSERT INTO $db_id.products (prod_no,prod_desc_eng,prod_desc_svk,main_cat_id,sub_cat_id,color_eng,color_svk,size,material_eng,material_svk,price,in_stock,pieces_in_stock,pic_small,pic_large)
VALUES('$prod_no','$prod_desc_eng','$prod_desc_svk',$main_cat_id,$sub_cat_id,'$color_eng','$color_svk','$size','$material_eng','$material_svk',$price,'$in_stock',$pieces_in_stock,'$pic_small','$pic_large')";
mysql_query($insert_new_query) or die('Error:'.mysql_error());any ideas?