我通常很擅長(zhǎng)這個(gè),當(dāng)我完成我的項(xiàng)目時(shí);我遇到了一個(gè)錯(cuò)誤。PDO 給了我一個(gè)語(yǔ)法錯(cuò)誤,我無(wú)法理解。也許我只是累了,但這讓我發(fā)瘋。這是我用于我的 PHP 代碼的內(nèi)容:$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ù)據(jù)庫(kù)如下: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;我得到的錯(cuò)誤是這樣的: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我什至嘗試過(guò):$records->bindParam(':theLimit', $_POST['email']);認(rèn)為它可能是 URL。同樣的錯(cuò)誤。我重做了數(shù)據(jù)庫(kù),同樣的錯(cuò)誤。有任何想法嗎?
為什么這會(huì)給我一個(gè)語(yǔ)法錯(cuò)誤?PHP PDO
ibeautiful
2022-01-24 09:42:19