Shane Heyworth
2011-05-13 11:50:51 UTC
$from = $_SESSION['user']['userid'];
$to = $_POST['client'];
$datetime = date("Y m d H:i:s");
$message = $_POST['messages'];
$read = 0;
$query = "INSERT INTO messages (messageid, from, to, datetime, message, read) VALUES (NULL,'$from','$to','$datetime','$message','$read')";
$result = mysql_query($query) or die(mysql_error());
}
Having a really stupid problem with this code.
When checking the echoes of it everything is posting. When I go to post into the SQL I get an error of this:
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, to, datetime, message, read) VALUES (NULL,'1','1','2011 05 13 14:46:37','T' at line 1
My table setup is as follows. Note that to and from and both userids:
messageid int 11 PRIMARY KEY
from int 11
to int 11
datetime datetime
message varchar 1000
read varchar 1
Please offer any and all advice. I'm sure I'm missing something stupid. I've rewrote the code like five times though.