我收到此错误错误: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 'to, from, message, read) VALUES ('3','2','testmessage','0')' at line 1.
我已经在这里待了几个小时,但在 SO 或任何其他站点都没有发现任何东西。提前感谢您的帮助。下面是一个简单的消息系统文件。
<?php
session_start();
$id = $_SESSION['id'];
$msg = $_POST['message'];
$theirs = $_POST['value'];
$read = 0;
$con = mysql_connect("127.0.0.1","root","");
mysql_select_db("test", $con);
if (!$con)
die('Could not connect: ' . mysql_error());
$sql = "INSERT INTO messages (to, from, message, read) VALUES ('$theirs','$id','$msg','$read')";
if (!mysql_query($sql,$con))
die('Error: ' . mysql_error());
mysql_close($con);