dshu1235 2014-04-25 07:25
浏览 102
已采纳

致命错误:调用未定义的函数bindParam()[关闭]

First of all, I already looked for the same questions, but couldn't find solutions. My db is working correctly. Everything is fine, except bindParam(). var_dump($expr) is also correct

$stmt = $pdo->prepare('SELECT * FROM tbl WHERE student_id = :student_id and exam_no = :exam_no');
$student_id = $_POST['student_id'];
$academic_year = $_POST['academic_year'];
$exam_no = $_POST['exam_no'];

$stmt->bindParam(':student_id', $student_id);

$stmt->bindParam(':exam_no', $exam_no);

$stmt->execute();

$blah = $stmt->fetchAll();
$expr = $pdo->prepare('SELECT english FROM tbl WHERE student_id = :student_id and exam_no = :exam_no');
$expr = bindParam(':exam_no', $exam_no);
$expr = bindParam(':student_id', $student_id);
$expr->execute();

Getting: "Fatal error: Call to undefined function bindParam()" where $expr = bindParam() is located

  • 写回答

1条回答 默认 最新

  • doulu4413 2014-04-25 07:27
    关注

    bindParam is a method of PDOStatement, not a global function. (It's odd you did right at first but wrong at second.)

    Change

    $expr = bindParam(':exam_no', $exam_no);
    $expr = bindParam(':student_id', $student_id);
    

    to

    $expr->bindParam(':exam_no', $exam_no);
    $expr->bindParam(':student_id', $student_id);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题