Php 您的SQL语法(mySQL)有错误
我知道以前也有人问过类似的问题,我看过这些主题,但似乎仍然找不到语法中的错误,所以我转而发表自己的观点Php 您的SQL语法(mySQL)有错误,php,mysql,insert-into,Php,Mysql,Insert Into,我知道以前也有人问过类似的问题,我看过这些主题,但似乎仍然找不到语法中的错误,所以我转而发表自己的观点 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 'INSERT_INTO users (uid,email,pass_hash,permissions,join_date) V
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 'INSERT_INTO users (uid,email,pass_hash,permissions,join_date) VALUES ('wright.ma' at line 1)
下面是我的代码,但在SQL之前,其他一切似乎都正常工作,这对我来说似乎是有效的
$email = $_POST['email'];
$pass = $_POST['pass'];
$pass2 = $_POST['pass2'];
$uid = $_POST['uid'];
$join_date = date("Y-m-d H:i:s");
if ($_POST['permissions']) { $permissions = $_POST['permissions']; } else { $permissions = 0; }
if (!$email) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Security Module Error - Email address not provided");
}
if (!$uid) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Security Module Error - User ID not provided");
}
if (!$pass || !$pass2 || ($pass != $pass2)) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Security Module Error - Password not provided or doesn't match");
}
$pass_hash = crypt($pass,'$1$$hash$1');
$conn = @mysql_connect("localhost","root","root");
if (!$conn) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Database Error - Unable to Connect");
}
$db = @mysql_select_db("start", $conn);
if (!$db) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Database Error - Unable to Access Database");
}
$result = @mysql_query("INSERT_INTO users (uid,email,pass_hash,permissions,join_date) VALUES ('$uid','$email','$pass_hash','$permissions',$join_date)");
if (!$result) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Database Error - Unable to Create Record (".mysql_error($conn).")");
}
$row = mysql_fetch_array($result);
if (!$row) {
header('HTTP/1.1 500 Internal Server Error');
header('Content-Type: application/json');
exit("Security Module Error - Unable to Authenticate Record Creation");
} else {
$_SESSION['uid'] = $row['uid'];
$_SESSION['permissions'] = $row['permissions'];
$_SESSION['email'] = $row['email'];
}
如果有第二双愿意帮忙的眼睛,我们将不胜感激 插入和插入之间用下划线分隔。语法应为“插入到…” 您还应该考虑使用PDO或mysqli,因为mysql_*函数已被弃用
INSERT INTO users
不是
好的,谢谢!现在我在其他地方得到了一个错误:在第1行“20:02:34”附近),它似乎与我的加入日期插入有关,这是我数据库中的日期时间。我以为我有正确的格式,但它看起来对你合适吗?你需要引用日期值。
INSERT_INTO users