elis Posted October 4, 2006 Share Posted October 4, 2006 I keep getting the following error:[quote]Query send failedYou 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,additional,sentdate,subject) VALUES ('','24,'Envi','','Jalee' at line 1[/quote]here's the code[code] $date = date('Y-m-d'); $send = "INSERT INTO report_user (id,ip,reported,rptmessage,by,additional,sentdate,subject) VALUES ('','$ip,'$_POST[reported]','$message','$userpenname','$add','$date','$sub')"; $sent = mysql_query($send) or die("Query send failed".mysql_error());[/code]I'm not sure what the problem is, I've looked at it a few times and I must be missing something... Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/ Share on other sites More sharing options...
Jocka Posted October 4, 2006 Share Posted October 4, 2006 it's always infront of where it says "near " and then gives that info. so i'm guessing this area:rptmessage,maybe its not rptmessage, maybe its misspelled. could be anything almost lol. Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103948 Share on other sites More sharing options...
tleisher Posted October 4, 2006 Share Posted October 4, 2006 Try this:[code]$date = date('Y-m-d');$reported = $_POST["reported"];$send = mysql_query("INSERT INTO report_user (id, ip, reported, rptmessage, by, additional, sentdate, subject) VALUES ('','$ip,'$reported','$message','$userpenname','$add','$date','$sub')") or die("Query send failed ".mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103951 Share on other sites More sharing options...
elis Posted October 4, 2006 Author Share Posted October 4, 2006 I just tried that, I got the same error again. :-[ Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103954 Share on other sites More sharing options...
tleisher Posted October 4, 2006 Share Posted October 4, 2006 Found it:Try this:$date = date('Y-m-d');$reported = $_POST["reported"];$send = mysql_query("INSERT INTO report_user (id, ip, reported, rptmessage, by, additional, sentdate, subject) VALUES ('','$ip[b]'[/b],'$reported','$message','$userpenname','$add','$date','$sub')") or die("Query send failed ".mysql_error());Forgot a single quote there :) Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103957 Share on other sites More sharing options...
elis Posted October 4, 2006 Author Share Posted October 4, 2006 Same error again :(I guess I'll have to try again from scratch? Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103963 Share on other sites More sharing options...
tleisher Posted October 4, 2006 Share Posted October 4, 2006 Try taking the ID part out? If your ID is autoincremental, you dont have to have that in there, and it may cause an error if you try to alter it. Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103970 Share on other sites More sharing options...
roopurt18 Posted October 4, 2006 Share Posted October 4, 2006 Instead of showing us the code that creates the query, try echoing the query itself. It's often easier to spot errors when looking at the finished query, without all the extra php syntax. Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103992 Share on other sites More sharing options...
roopurt18 Posted October 4, 2006 Share Posted October 4, 2006 Also, try entering the query through phpMyAdmin; you may have spelled one of your columns incorrectly and it'll catch it. Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-103993 Share on other sites More sharing options...
printf Posted October 4, 2006 Share Posted October 4, 2006 there is nothing wrong with the query, it you COLUMN NAMINGby = reserved word!I recommend you change that column name, or use backtic operators to enclose it `by`, but that's bad logic, because the MySQL road map states it's going to put more restrictions on reserved words in furtue versions of MySQL!!!me! Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-104000 Share on other sites More sharing options...
elis Posted October 5, 2006 Author Share Posted October 5, 2006 ^ Ah, the 'by' was the problem as you said. Thank you all for your help. Now, it's finally working correctly. Quote Link to comment https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/#findComment-104223 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.