gpt4 book ai didi

php - Mysql表不存在,但确实存在

转载 作者:太空宇宙 更新时间:2023-11-03 10:52:46 26 4
gpt4 key购买 nike

我有一个奇怪的错误,使用 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 ">>";

关于造成这种情况的原因有什么想法吗?

最佳答案

您拼错了 User_Accounts。您创建的表是 User.User_Accounts,但不存在的表是 User.User_Acounts

关于php - Mysql表不存在,但确实存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23164881/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com