我使用以下代码段从学生表中选择行数。但它显示错误"致命错误:在非对象上调用成员函数bind_param()"。在我的桌子' stacyear'是VARCHAR,' courseid'是TINY INT。
$stmt = $mysqli->prepare("SELECT count (*) FROM students WHERE stacyear = ? and courseid = ?");
$stmt->bind_param('si', $acyear, $courseid);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($utype);
$stmt->fetch();
答案 0 :(得分:2)
您不能在COUNT
和(*)
之间留出空格。改为
$stmt = $mysqli->prepare("SELECT count(*) FROM students WHERE stacyear = ? and courseid = ?");