jeff5656 Posted January 23, 2010 Share Posted January 23, 2010 This code worked until I added the variable "change". Weird - is change a reserved word or something? $change = mysql_real_escape_string($_POST['change']); --snip-- $query = "INSERT INTO hrct (hrct_id, pt_id, change, description, hrct_date) VALUES('','$pt_id', '$change', '$description', '$hrct_date')"; mysql_query($query) or die(mysql_error()); The error is 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 'change, description, hrct_date) VALUES('','10', '', 'Description', '1969-12-' at line 1 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/189535-syntax-error-in-query/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 23, 2010 Share Posted January 23, 2010 is change a reserved word You could always look that up in the documentation to find out the answer yourself - http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html Quote Link to comment https://forums.phpfreaks.com/topic/189535-syntax-error-in-query/#findComment-1000430 Share on other sites More sharing options...
jeff5656 Posted January 23, 2010 Author Share Posted January 23, 2010 That was a really helpful reply! :-) But seriously, does anyone know what could be wrong with my code and why it gives me a syntax error? It's really strange - it looks like it *should* work. Quote Link to comment https://forums.phpfreaks.com/topic/189535-syntax-error-in-query/#findComment-1000440 Share on other sites More sharing options...
bl00dshooter Posted January 23, 2010 Share Posted January 23, 2010 It was really a helpful answer, if you took 5 secs of your time. Quote Link to comment https://forums.phpfreaks.com/topic/189535-syntax-error-in-query/#findComment-1000443 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.