richrock Posted January 8, 2009 Share Posted January 8, 2009 Hi all, Having a little problem with my mysql insert in PHP, not sure which forum to have it in. Here's the code: // Insert the copied lot into the unassigned lots listings $put_CopiedLot = "INSERT INTO jos_bid_auctions "; $put_CopiedLot .= "(userid, title, shortdescription, "; $put_CopiedLot .= "description, picture, initial_price, "; $put_CopiedLot .= "automatic, shipment_info, reserve_price, "; $put_CopiedLot .= "cat, vat_rate, est_low, est_high, "; $put_CopiedLot .= "outside_eu, condition, receipt_num, "; $put_CopiedLot .= "lot_num, keywords, maker, "; $put_CopiedLot .= "age, rec_num, line_num, "; $put_CopiedLot .= "con_rec_num, lot_order) "; $put_CopiedLot .= "VALUES ("; $put_CopiedLot .= "'".$userid."', '".$title."', '".$shortdesc."', "; $put_CopiedLot .= "'".$description."', '".$picture."', '".$initial_price."', "; $put_CopiedLot .= "'".$automatic."', '".$shipment_info."', '".$reserve_price."', "; $put_CopiedLot .= "'1', '".$vat_rate."', '".$est_low."', '".$est_high."', "; $put_CopiedLot .= "'".$outside_eu."', '".$condition."', '".$receipt_num."', "; $put_CopiedLot .= "'".$lot_num."', '".$keywords."', '".$maker."', "; $put_CopiedLot .= "'".$age."', '".$rec_num."', '".$line_num."', "; $put_CopiedLot .= "'".$con_rec_num."', '".$lot_order."') "; echo $put_CopiedLot; $rCopiedLot = mysql_query($put_CopiedLot) or die(mysql_errno() . mysql_error()); I can't see anything wrong with it, but it reports an error: "1064You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition, receipt_num, lot_num, keywords, maker, age, rec_num, line_num, con_re' at line 1" Now I've figured out from previous errors like this that it's usually just before the part of the query that's actually quoted... But I can't see anything wrong with the code. I kept the names the same for ease of use here, and the spelling is OK... It was all cut and pasted so if there are any errors it should be right at the start, but nooooo..... Mysql Ver: 5.0.51a-community-nt running on Wamp Server 2 Maybe I haven't had enough coffee or too much :-\ Quote Link to comment https://forums.phpfreaks.com/topic/139983-solved-am-i-missing-something/ Share on other sites More sharing options...
GingerRobot Posted January 8, 2009 Share Posted January 8, 2009 Can we see the output from this line? echo $put_CopiedLot; It's usually much easier to see the sql syntax error when you havn't got all the php confusing things. Quote Link to comment https://forums.phpfreaks.com/topic/139983-solved-am-i-missing-something/#findComment-732372 Share on other sites More sharing options...
richrock Posted January 8, 2009 Author Share Posted January 8, 2009 Okay - tho I just copied the error bit. INSERT INTO jos_bid_auctions (userid, title, shortdescription, description, picture, initial_price, automatic, shipment_info, reserve_price, cat, vat_rate, est_low, est_high, outside_eu, condition, receipt_num, lot_num, keywords, maker, age, rec_num, line_num, con_rec_num, lot_order) VALUES ('7807', 'A Guitar by Louis Panormo, London 1837', 'A Guitar by Louis Panormo, London 1837', 'A Guitar by Louis Panormo, London 1837 Labelled: Louis Panormo the only maker of guitars in the Spanish style...Bloomsbury...London 1837 The back and ribs of rosewood, the table of medium grain spruce, the sound hole set with concentric circles inlaid with mother of pearl lozenges, the bone rollers, the brass machines by Rance, the mother of pearl tuners, the head stock stamped: Pratten, and bearing the seal of Sydney Pratten, a stylised monograph in red wax', '1005/1_Lot-108f.jpg', '1', '0', '', '0', '1', '', '1200', '1800', '', 'Good', '0', '108', 'guitar', '', '', '3218', '1', '0', '2') 1064 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 'condition, receipt_num, lot_num, keywords, maker, age, rec_num, line_num, con_re' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/139983-solved-am-i-missing-something/#findComment-732373 Share on other sites More sharing options...
fenway Posted January 8, 2009 Share Posted January 8, 2009 CONDITION is a reserved keyword... Quote Link to comment https://forums.phpfreaks.com/topic/139983-solved-am-i-missing-something/#findComment-732508 Share on other sites More sharing options...
richrock Posted January 8, 2009 Author Share Posted January 8, 2009 Bummer! Well, I can add an _instr (it's the condition of the instrument) to the database column and I'll have to update the other insert entry on another page, not too much hassle. Thanks for your help! ;D Rich Quote Link to comment https://forums.phpfreaks.com/topic/139983-solved-am-i-missing-something/#findComment-732520 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.