Jump to content

[SOLVED] Simple INSERT problem (i think ?)


TheStalker

Recommended Posts

Hi i am trying to insert data into a MySql database and keep getting the following error:

 

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, subject, message, date, time, sentOrReceived) VALUES (0, '12', '2', 'hello' at line 1

 

i have the follwing set up in my database

 

messageID -int(11)  No  auto_increment             

from- varchar(100)       

subject -varchar(250)               

message -varchar(1000)               

date- date                   

time- time

sentOrReceived- varchar(7)

 

Here is the SQL code i am using:

$time = date("H:i:s",time());
$date = date("d/m/Y");

$messageID = mysql_insert_id();

$sql = "INSERT INTO messaging (messageID, from, subject, message, date, time, sentOrReceived) VALUES (".$messageID.", '".$_POST["from"]."', '".$_POST["subject"]."', '".$_POST["message"]."', ".$date.", ".$time.", ".sent.")"; 

 

 

Link to comment
https://forums.phpfreaks.com/topic/134543-solved-simple-insert-problem-i-think/
Share on other sites

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.