0

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?

1
  • use User_Accounts instead of User_Acounts. spelling is incorrect in $query = "INSERT INTO User_Acounts Commented Apr 19, 2014 at 1:54

3 Answers 3

2

You've misspelled User_Accounts. The table you created is User.User_Accounts but the table that doesn't exist is User.User_Acounts.

Sign up to request clarification or add additional context in comments.

2 Comments

Augh. This is proof I need a break. Such a dumb mistake. Thanks
Ha, it happens to all of us.
1

You wrote accounts with one c

Table 'Users.User_Acounts' doesn't exist

Comments

1

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 )";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.