簡體   English   中英

MySQL表不存在,但確實存在

[英]Mysql table doesnt exist, but it does

我有一個奇怪的錯誤,使用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

您用一個c來寫帳戶

Table 'Users.User_Acounts' doesn't exist

表名是User_Accounts 在您的php代碼中,將其拼寫為User_Acounts

更正為

$ query =“將INERT插入User_Accounts(用戶名,電子郵件,Phon2eNumber,密碼)VALUES(:name,:email,:phone,:pass)”;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM