Jump to content

Second set of eyes? INSERT error


elis

Recommended Posts

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...
Link to comment
https://forums.phpfreaks.com/topic/23020-second-set-of-eyes-insert-error/
Share on other sites

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]
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 :)
there is nothing wrong with the query, it you COLUMN NAMING

by = 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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.