WarKirby Posted January 1, 2010 Share Posted January 1, 2010 Having an error with an insert query. Maybe this should go in the mysql forum, not certain $result = mysql_query("INSERT INTO ".$dbSalesTable." (customerKey,customerName,articleNumber,productName,pricePaid,timeSold,vendorRegion) VALUES(".$customerKey.",".$customerName.",".$row[articleNumber].",'".getProductName($row[contentArticle])."','0',".$timeSold.",".$vendorRegion.")") or die(mail($to, "Error inserting content", mysql_error())); the mail call is me emailing myself the mysql error, since this script is being run by another. It gives me an error for this line which reads: 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 'Test Product,'0',1262328364,'Ferox')' at line 1 Test Product being the productname. It seems that the problem is around there. Link to comment https://forums.phpfreaks.com/topic/186836-what-is-wrong-with-this-query/ Share on other sites More sharing options...
trq Posted January 1, 2010 Share Posted January 1, 2010 You should save you query into a variable then echo it to see what it actually looks like. You may be missing some quotes. Link to comment https://forums.phpfreaks.com/topic/186836-what-is-wrong-with-this-query/#findComment-986679 Share on other sites More sharing options...
fareedreg Posted January 1, 2010 Share Posted January 1, 2010 $query= "INSERT INTO ".$dbSalesTable." (customerKey,customerName,articleNumber,productName,pricePaid,timeSold,vendorRegion) VALUES(".$customerKey.",".$customerName.",".$row[articleNumber].",'".getProductName($row[contentArticle])."','0',".$timeSold.",".$vendorRegion."); $result = mysql_query($query,<database link>); Link to comment https://forums.phpfreaks.com/topic/186836-what-is-wrong-with-this-query/#findComment-986688 Share on other sites More sharing options...
WarKirby Posted January 1, 2010 Author Share Posted January 1, 2010 ah, solved now. Silly mistake of course. Where I used $row[articleNumber] that should have been $row[contentArticle]. The articlenumber column doesn't exist in the table it's querying, since that table stores pairs of two articles. Link to comment https://forums.phpfreaks.com/topic/186836-what-is-wrong-with-this-query/#findComment-986694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.