wigglyworm91 Posted September 12, 2009 Share Posted September 12, 2009 Whoever wants to take this on.... Alright, been trying at this for a while now, can't figure out what the error is looking at, I can understand it lol. //In a hidden form field, output the number of hours added, just in case the user wants to undo her actions echo "<form><input type=\"hidden\" value=\"$hours\" name=\"prev_hours\"></input></form>"; //Update database data --> $query = "INSERT INTO `jhs_records`.`School` (ID, First, Last, Sep, Oct, Nov, Dec, Jan, Feb, Mar, Apr, May, Total) VALUES ('$ID', '$first', '$last', '$aug', '$sep', '$oct', '$nov', '$dec', '$jan', '$feb', '$mar', '$apr', '$may', '$total')"; <-- mysql_query($query) or die(mysql_error()); The arrows point to the line it points out when it squawks at me. It gives me, " 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 'Dec, Jan, Feb, Mar, Apr, May, Total) VALUES ('18072', 'Michael', " All variables exist and are strings. (obviously, 18072 and Michael are the current values of these vars.) Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/173965-solved-phpmysql-help-syntax-for-an-insert-statement/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 12, 2009 Share Posted September 12, 2009 The starting part of the query that was printed in the error message is where mysql found something it could not understand. Dec is a reserved keyword and should not be used as a column name - http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html You should rename it to something else. If you do need to use a reserved keyword as a column name you must enclose it in back-ticks ` Quote Link to comment https://forums.phpfreaks.com/topic/173965-solved-phpmysql-help-syntax-for-an-insert-statement/#findComment-917001 Share on other sites More sharing options...
grissom Posted September 12, 2009 Share Posted September 12, 2009 Easy ! One half of your insert statement starts with the month of august, the other half starts with the month of september. Quote Link to comment https://forums.phpfreaks.com/topic/173965-solved-phpmysql-help-syntax-for-an-insert-statement/#findComment-917354 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.