Jump to content

problem with a pdo execute of an insert query


markschum
Go to solution Solved by markschum,

Recommended Posts

I had this unning on my local apache server but when I uploaded it to the hosting site it fails with the error shown.

 

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /home/thusuo5/public_html/interestingthings.biz/index.php on line 77 

 

The try except The error isnt being trapped so the warning appears on the web page with the order processed message.

 

I have counted everything, see no spelling or punctuation errors.

 

the website is interestingthings.biz  hosted by innovision.

 

I am trying to do this for a family member and as a learning exercise.

 

Thanks for any help.

 try {
        $dbh = new PDO('mysql:host=localhost;dbname=orders', 'user', 'password');
    /*** INSERT data ***/
    /*** set up the query ***/    
        $qry = "INSERT INTO   new(type,style,material,ring,finish,font,text,name,address, email, orderdate,ip)     VALUES (:ftype,:fstyle,:fmaterial,:fring,:ffinish,:ffont,:ftext,:fname, :faddress, :fcity, fzipcode, :femail, :orderdate,:ip )";
        $query = $dbh -> prepare($qry);
    /*** run the insert ***/
        $result = $query->execute(array(
            ":ftype" => $ftype,
            ":fstyle" => $fstyle,        
            ":fmaterial" => $fmaterial,
            ":fring" => $fring,
            ":ffinish" => $ffinish,
            ":ffont" => $ffont,
            ":ftext" => $ftext,
            ":fname" => $fname,
            ":faddress" => $faddress,
            ":fcity" => $fcity,
            ":fzipcode" => $fzipcode,            
            ":femail" => $femail,
            ":orderdate" => $fdate,
            ":ip" => $ip
            ));
    /*** close the database connection ***/
        $dbh = null;
/* order placed */
     $errmessage = 'your order has been placed , thanks ';  
// fatal error trap
    } catch(PDOException $e) {
        echo "Sorry there has been an error -". $e->getMessage() . '<br><br>';
        echo "Please press the BACK button on your browser and try again ";
        }
    }

Thanks again for any help.

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.