quickstopman Posted June 13, 2007 Share Posted June 13, 2007 hey guys i keep getting this mysql error for no reason here is the code $addfriend = mysql_query("INSERT INTO friends (friendID, name, userid, from, fr_reqid, accepted) VALUES ('$friendID', '$name', '$id', '{$_SESSION['knickname']}')") or die(mysql_error()); i have no idea why its giving me an error any ideas?? * here is the 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 'from, fr_reqid, accepted) VALUES ('2', 'Bob', '1', 'HERRO!!!!!!!!!!!!')' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/55470-solved-mysql-error/ Share on other sites More sharing options...
Wildbug Posted June 13, 2007 Share Posted June 13, 2007 (You forgot to post the error.) Your number of columns don't match. Fix it on either end. Quote Link to comment https://forums.phpfreaks.com/topic/55470-solved-mysql-error/#findComment-274134 Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 $addfriend = mysql_query("INSERT INTO friends (friendID, name, userid, from, fr_reqid, accepted) VALUES ('$friendID', '$name', '$id', '{$_SESSION['knickname']}', 'NULL', 'no')") or die(mysql_error()); now i get the same error agiain it just cuts off NULL and makes it NU here 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 'from, fr_reqid, accepted) VALUES ('4', 'frosteh', '1', 'HERRO!!!!!!!!!!!!', 'NU' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/55470-solved-mysql-error/#findComment-274137 Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 ok i fixed it somehow bye! Quote Link to comment https://forums.phpfreaks.com/topic/55470-solved-mysql-error/#findComment-274144 Share on other sites More sharing options...
Wildbug Posted June 13, 2007 Share Posted June 13, 2007 FROM is a reserved keyword. Enclose it in backticks (` = shift-~, not single quote). Also, don't put quotes around NULL. Quote Link to comment https://forums.phpfreaks.com/topic/55470-solved-mysql-error/#findComment-274147 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.