Jump to content

problem with a pdo execute of an insert query


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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.