我通常很擅長這個,當我完成我的項目時;我遇到了一個錯誤。PDO 給了我一個語法錯誤,我無法理解。也許我只是累了,但這讓我發(fā)瘋。這是我用于我的 PHP 代碼的內容:$records = $conn->prepare('INSERT INTO users (username, email, password, limit) VALUES (:username, :email, :password, :theLimit)');$records->bindParam(':username', $_POST['username']);$records->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));$records->bindParam(':email', $_POST['email']);$records->bindParam(':theLimit', $_GET['amt']);我的數(shù)據庫如下:CREATE TABLE `users` ( `id` int(11) UNSIGNED NOT NULL, `username` varchar(250) NOT NULL DEFAULT '', `email` varchar(250) NOT NULL DEFAULT '', `password` varchar(200) NOT NULL DEFAULT '', `limit` varchar(200) NOT NULL DEFAULT '', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;我得到的錯誤是這樣的:Array ( [0] => 42000 [1] => 1064 [2] => 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 'limit) VALUES ('F', 'some_person@email.com', '$2y$10$gacC/a8zA3jCbPpKNTddtu4dBG' at line 1 )最后,URL 如下所示:https://website.com/reg.php?serial=306019525D31&amt=10我什至嘗試過:$records->bindParam(':theLimit', $_POST['email']);認為它可能是 URL。同樣的錯誤。我重做了數(shù)據庫,同樣的錯誤。有任何想法嗎?
為什么這會給我一個語法錯誤?PHP PDO
ibeautiful
2022-01-24 09:42:19