我知道这个问题被问了一千多次,但我确实遇到了这个问题。最近我一直在我自己的网站上工作并试图用login db
语句(PHP,MySQL)更新insert
,但每次我都收到相同的错误消息:
INSERT INTO登录(ldate,uid)VALUES(now(),'')
你有错误 在你的SQL语法中;查看与MySQL对应的手册 服务器版本,用于在']附近使用正确的语法。'在第1行;
MySQL表:
+-------+-----------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------------+------+-----+-------------------+----------------+
| lid | int(6) unsigned | NO | PRI | NULL | auto_increment |
| ldate | timestamp | NO | | CURRENT_TIMESTAMP | |
| uid | int(6) unsigned | NO | MUL | NULL | |
PHP代码:
if(isset($_POST["login"])){
require("connect.php");
$email = strip_tags(trim($_POST["email"]));
$password = strip_tags(trim($_POST["password"]));
$passwordSha = sha1($password);
$sql = ("SELECT pemail,upass FROM personalDetails,passwords WHERE personalDetails.pemail='".$email."'"
. " AND passwords.upass='".$passwordSha."'LIMIT 1");
$result = $conn->query($sql);
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
$id = $row["uid"];
if($row["pemail"] === $email && $row["upass"] === $passwordSha){
echo $row['pemail'];
$uid = $row["uid"];
$sql = "INSERT INTO logins (ldate,uid) VALUES (now(),'$uid')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . " " . mysqli_error($conn);
}
}else{
echo "0 results";
}
}
任何建议将不胜感激。谢谢!
排序谢谢