aquanuke Posted September 1, 2011 Share Posted September 1, 2011 mysql_query("INSERT INTO invoices ( client, date, domains, items, each, cost, status) VALUES('$custom', '$date', '$item_number Domain Credits', '1', '$mc_gross', '$mc_gross', 'PAID' ) ") or die(mysql_error()); gives me 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 'each, cost, status) VALUES('admin', '2011-09-01', '10 Domain Credits', '1', '15'' at line 2 Using crimson editor the fields im selecting 'date' and 'each' are in red. Are they not allowed? me thinking out loud Link to comment https://forums.phpfreaks.com/topic/246215-whats-wrong-with-this-mysql-insert/ Share on other sites More sharing options...
Pikachu2000 Posted September 1, 2011 Share Posted September 1, 2011 each is a MySQL reserved word. Link to comment https://forums.phpfreaks.com/topic/246215-whats-wrong-with-this-mysql-insert/#findComment-1264495 Share on other sites More sharing options...
aquanuke Posted September 1, 2011 Author Share Posted September 1, 2011 Thanks thats what I thought, so is there a way to escape it like enclose the fields? I cant change the db fields as this table has been in use for about 7 years and tons of references to it elsehwere in other scripts. Link to comment https://forums.phpfreaks.com/topic/246215-whats-wrong-with-this-mysql-insert/#findComment-1264497 Share on other sites More sharing options...
Pikachu2000 Posted September 1, 2011 Share Posted September 1, 2011 Enclose it in `backticks` in the query string. Link to comment https://forums.phpfreaks.com/topic/246215-whats-wrong-with-this-mysql-insert/#findComment-1264498 Share on other sites More sharing options...
aquanuke Posted September 1, 2011 Author Share Posted September 1, 2011 Thank you ! Link to comment https://forums.phpfreaks.com/topic/246215-whats-wrong-with-this-mysql-insert/#findComment-1264502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.