我有一个奇怪的错误,使用MyPhpAdmin,我添加了一行,它生成的脚本是:
INSERT INTO 'Users'.'User_Accounts'('Account_ID', 'UserName',
'Email', 'PhoneNumber', 'Password') VALUES (NULL, 'fdsfsadf',
'dfsadf', 'sdfads', 'fsdfasdfsd');
这是有效的,但是当我使用PHP PDO插入它时会出现此错误:
Table 'Users.User_Acounts' doesn't exist
嗯,是的,它确实......
PHP代码:
$hostname = "127.0.0.1";
$port = "3306";
$database = "Users";
$username = "AccountControl";
$password = "w67hLAanWESGNJMC";
echo ">>";
$db = new PDO("mysql:host=$hostname; port=$port; dbname=$database", $username, $password);
echo ">>";
$UserName = "KiteDev";
$Email = "johndoveail.com";
$PhoneNumber = "66666";
$Password = "dfsgetagfdasg";
// Create the query
$query = "INSERT INTO User_Acounts (UserName, Email, Phon2eNumber, Password) VALUES (:name, :email, :phone, :pass )";
// Prepare statement with $stmt variable
$stmt = $db->prepare($query);
echo ">>";
// Bind parameters, (you can also remove the PDO::PARAM_INT)
$stmt->bindParam(':name', $UserName, PDO::PARAM_STR);
$stmt->bindParam(':email', $Email, PDO::PARAM_STR);
$stmt->bindParam(':phone', $PhoneNumber, PDO::PARAM_STR);
$stmt->bindParam(':pass', $Password, PDO::PARAM_STR);
// Execute the query once you're done binding all the params
$stmt->execute() or die(print_r($stmt->errorInfo(), true));
echo ">>";
关于导致这种情况的任何想法?
答案 0 :(得分:2)
你拼错了User_Accounts
。您创建的表格为User.User_Accounts
,但不存在的表格为User.User_Acounts
。
答案 1 :(得分:1)
您使用一个c
编写了帐户Table 'Users.User_Acounts' doesn't exist
答案 2 :(得分:1)
表名为User_Accounts
。在您的PHP代码中,它拼写错误为User_Acounts
将其更正为
$ query =“INSERT INTO User_Accounts(UserName,Email,Phon2eNumber, 密码)VALUES(:name,:email,:phone,:pass)“;