doujian3132 2014-12-15 18:09
浏览 30
已采纳

PHP代码更新表时出错[关闭]

I am facing an error in this following function in my class.

<?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');

Error message is :

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

What is the issue here? I missed anything i dont see the issue with my sleepy eyes...

var_dump result is:

 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条回答 默认 最新

  • dsfdsf8888 2014-12-15 18:12
    关注

    Basically the problem is that you are specifying too many columns or too many values for those columns in your sql statement. You have col1, col2, col3.... val1, val2... <-- too many columns for the number of values OR vice versa.... col1, col2.... val1, val2, val3.

    Try to echo your query before it is executed and you will see the mismatch.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动