首先,我已经找到了相同的问题,但找不到解决方案。我的数据库工作正常。一切都很好,除了bindParam()。 var_dump($ expr)也是正确的
$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();
获取:“致命错误:调用未定义的函数bindParam()”其中$ expr = bindParam()位于
答案 0 :(得分:5)
bindParam
是PDOStatement
的方法,而不是全局函数。 (你开始做的很奇怪,但第二次做错了。)
更改
$expr = bindParam(':exam_no', $exam_no);
$expr = bindParam(':student_id', $student_id);
到
$expr->bindParam(':exam_no', $exam_no);
$expr->bindParam(':student_id', $student_id);