简体   繁体   中英

Mysql table doesnt exist, but it does

I have a weird error, using MyPhpAdmin, I added a row, and the script it generates is:

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:

Table 'Users.User_Acounts' doesn't exist

uhhhh yes it does...

The PHP code:

$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 . The table you created is User.User_Accounts but the table that doesn't exist is User.User_Acounts .

您用一个c来写帐户

Table 'Users.User_Acounts' doesn't exist

The Table Name is User_Accounts . In your php code, it is misspelled as User_Acounts

Correct it as

$query = "INSERT INTO User_Accounts (UserName, Email, Phon2eNumber, Password) VALUES (:name, :email, :phone, :pass )";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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