首先,我已经在寻找相同的问题,但找不到解决方案。我的数据库工作正常。除了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();
获取:“ fatal error :调用未定义的函数bindParam()”,其中$expr = bindParam()所在位置
最佳答案
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);
关于php - fatal error : Call to undefined function bindParam(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23286715/