我有无数的错误检查器,其最近输入的代码成功地满足要求,但是,这些数据似乎并不要进入数据库。它没有更新,因此,我认为那里有什么问题我行的更新代码
"UPDATE user (user_username, user_first, user_last, user_email) VALUES ('$uname', '$first', '$last', '$email');";
基本上要在我的输入框中键入新的信息将被插入到数据库
@添的回答号楼上,你应该也用事先准备好的声明。准备好的语句会保护你从MySQL注入,这有可能破坏你的数据库。
http://php.net/manual/en/pdo.prepared-statements.php
<?php
$stmt = $dbh->prepare("INSERT INTO user (user_username, user_first, user_last, user_email) VALUES (:usr, :first, :last, :email)");
$stmt->bindParam(':usr', $uname);
$stmt->bindParam(':first', $first);
$stmt->bindParam(':last', $last);
$stmt->bindParam(':email', $email);
$stmt->execute();
?>
你不使用MySQL的语法插入新行:
INSERT INTO tblName (col1, col2, col3) VALUES (x, y, z);
你有UPDATE
关键字。
将数据插入你查询将被
INSERT INTO user (user_username, user_first, user_last, user_email)
VALUES ('$uname', '$first', '$last', '$email')
但是,如果你想更新数据,您需要正确使用UPDATE子句。