PHP代码更新表时出错

时间:2014-12-15 18:09:18

标签: php

我在班上的这个函数中遇到错误。

<?php
  if(isset($_REQUEST['customer_id'])){

    $customer_id = $_REQUEST['customer_id'];

  }
      ?>
<?php     
 if ($_SERVER["REQUEST_METHOD"] == "POST")
{

$data = array(

        $_POST['customer_name'],
        $_POST['customer_address'], 
        $_POST['customer_phone'], 
        $_POST['customer_email']
        );

var_dump($data);


$update = DB::update('customer',$data,$customer_id,'customer_id');

错误信息是:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in 

这是什么问题?我错过了任何我没有看到困眼的问题......

var_dump结果是:

 array (size=4)
 0 => string 'Foo M' (length=5)
 1 => string 'Foo Lab' (length=17)
 2 => string '2147483647' (length=10)
 3 => string 'foo@moo.com' (length=11)

1 个答案:

答案 0 :(得分:0)

基本上问题是您在sql语句中为这些列指定了太多列或太多值。你有col1,col2,col3 .... val1,val2 ...&lt; - 值数太多的列,反之亦然.... col1,col2 .... val1,val2,val3。< / p>

尝试在执行之前回显您的查询,您将看到不匹配。