Jump to content

PDO insert in to {HELP!}


Freid001

Recommended Posts

Not sure what is wrong here: 

 

$query = "INSERT INTO `*******`(`account`, `capital`, `image`, `government`, `oil`, `wood`, `copper`, `iron`, `steel`, `titanium`) VALUES(:account, :capital, :image, :government, :oil, :wood, :copper, :iron, :steel, :titanium)";
$statement = $db->prepare($query);
$statement->execute(array(':account' => $user, ':capital' => $capital, ':image' => $image, ':government' => $government, ':oil' => $oil, ':wood' => $wood, ':cooper' => $copper, ':iron' => $iron, ':steel' => $steel, ':titanium' => $titanium));

 

 

THIS IS THE ERROR I GET:

 

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in/srv/disk5/657046/www/worldwarfare-v3.atwebpages.com/pages/registration/registration_script.php on line 175


Thanks for any help :)

Edited by Freid001
Link to comment
Share on other sites

Ok so no errors show up now. However i'm not sure if the query is being run because nothing gets inserted in to the database. I have checked that it is the correct table name and everything, so not sure why it is not inserting in to the table. Any ideas, or help? 

Link to comment
Share on other sites

Not sure why but its like the code is not being executed or something, any ideas? 

 

$query = "INSERT INTO `*******`(`account`, `capital`, `image`, `government`, `oil`, `wood`, `copper`, `iron`, `steel`, `titanium`) VALUES(:account, :capital, :image, :government, :oil, :wood, :copper, :iron, :steel, :titanium)";
$statement = $db->prepare($query);
$statement->execute(array(':account' => $user, ':capital' => $capital, ':image' => $image, ':government' => $government, ':oil' => $oil, ':wood' => $wood, ':copper' => $copper, ':iron' => $iron, ':steel' => $steel, ':titanium' => $titanium));
Edited by Freid001
Link to comment
Share on other sites

Try capturing errors. Check my signature where it says Debugging your SQL. You're not checking for any MySQL errors.

 

Edit: The post describes using mysqli, but you'll do the same thing with the appropriate PDO functions. Check the PHP manual for those.

Edited by Jessica
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.