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 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分