简体   繁体   English

MySQL表不存在,但确实存在

[英]Mysql table doesnt exist, but it does

I have a weird error, using MyPhpAdmin, I added a row, and the script it generates is: 我有一个奇怪的错误,使用MyPhpAdmin,添加了一行,它生成的脚本是:

INSERT INTO 'Users'.'User_Accounts'('Account_ID', 'UserName',
'Email', 'PhoneNumber', 'Password') VALUES (NULL, 'fdsfsadf',
'dfsadf', 'sdfads', 'fsdfasdfsd');

That works, however when I use PHP PDO to insert it gives this error: 那行得通,但是当我使用PHP PDO插入时会出现此错误:

Table 'Users.User_Acounts' doesn't exist

uhhhh yes it does... 嗯是的

The PHP code: 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 ">>";

Any ideas as to what's causing this? 关于什么原因的任何想法?

You've misspelled User_Accounts . 您拼错了User_Accounts The table you created is User.User_Accounts but the table that doesn't exist is User.User_Acounts . 您创建的表是User.User_Accounts但不存在的表是User.User_Acounts

您用一个c来写帐户

Table 'Users.User_Acounts' doesn't exist

The Table Name is User_Accounts . 表名是User_Accounts In your php code, it is misspelled as User_Acounts 在您的php代码中,将其拼写为User_Acounts

Correct it as 更正为

$query = "INSERT INTO User_Accounts (UserName, Email, Phon2eNumber, Password) VALUES (:name, :email, :phone, :pass )"; $ query =“将INERT插入User_Accounts(用户名,电子邮件,Phon2eNumber,密码)VALUES(:name,:email,:phone,:pass)”;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM