supermerc Posted February 25, 2009 Share Posted February 25, 2009 Hey this is a simple insert query but im getting an error and I just cant see why, if anyone sees something wrong with it could you please tell me? $sql = "INSERT INTO bonusaps(name, by, reason, aps, date) VALUES ('{$_SESSION[s_username]}', 'self', 'Potion Set', '30', '{$today}')"; getting the error MySQL Error: INSERT INTO bonusaps(name, by, reason, aps, date) VALUES ('ServeD', 'self', 'Potion Set', '30', 'February 25, 2009, 12:53 pm') 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 'by, reason, aps, date) VALUES ('ServeD', 'self', 'Potion Set', '30', 'February 2' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/146921-insert-query-trouble/ Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 By is a reserved word. Either rename that column or surround it in backticks (`) $sql = "INSERT INTO bonusaps(name, `by`, reason, aps, date) VALUES ('{$_SESSION[s_username]}', 'self', 'Potion Set', '30', '{$today}')"; Quote Link to comment https://forums.phpfreaks.com/topic/146921-insert-query-trouble/#findComment-771332 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.