Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.