Freid001 Posted May 28, 2013 Share Posted May 28, 2013 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 Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/ Share on other sites More sharing options...
Jessica Posted May 28, 2013 Share Posted May 28, 2013 cooper != copper. You should normalize that table. Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432766 Share on other sites More sharing options...
Freid001 Posted May 28, 2013 Author Share Posted May 28, 2013 Arh, cool thx mist that. How would I normalize the table? Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432767 Share on other sites More sharing options...
Jessica Posted May 28, 2013 Share Posted May 28, 2013 You missed it. Mist is when you have water in a fine spray. Google "normalize your data". Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432768 Share on other sites More sharing options...
Freid001 Posted May 28, 2013 Author Share Posted May 28, 2013 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 https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432825 Share on other sites More sharing options...
Freid001 Posted May 29, 2013 Author Share Posted May 29, 2013 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)); Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432964 Share on other sites More sharing options...
Jessica Posted May 29, 2013 Share Posted May 29, 2013 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. Link to comment https://forums.phpfreaks.com/topic/278483-pdo-insert-in-to-help/#findComment-1432976 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.