这个旧查询工作正常,但是当我添加
时 $statement->store_result();
$rows = $statement->num_rows;
添加store_result和num_rows后,我收到此错误消息:
致命错误:在布尔值
上调用成员函数fetch_assoc()
我不能使用bind_result。
有没有办法解决这个问题,还是应该为num_rows进行第二次查询?
旧查询:
$mw_gegevens_qry = "SELECT
*
FROM
mw_gegevens
WHERE
mw_gegevens_persnr=?
AND
mw_gegevens_pass=?
AND
mw_gegevens_pass!=''
";
$statement = $connection->prepare($mw_gegevens_qry);
if($qry === false){
echo "Query error:.". $connection->error();
}else{
$statement->bind_param('is', $user, $userpassword);
$statement->execute();
$result = $statement->get_result();
$mwgegevens = $result->fetch_assoc();
新查询
$mw_gegevens_qry = "SELECT
*
FROM
mw_gegevens
WHERE
mw_gegevens_persnr=?
AND
mw_gegevens_pass=?
AND
mw_gegevens_pass!=''
";
$statement = $connection->prepare($mw_gegevens_qry);
if($qry === false){
echo "Query error:.". $connection->error();
}else{
$statement->bind_param('is', $user, $userpassword);
$statement->execute();
$statement->store_result();
$rows = $statement->num_rows;
$result = $statement->get_result();
$mwgegevens = $result->fetch_assoc();
答案 0 :(得分:0)
$mw_gegevens_qry = "
SELECT
*
FROM
mw_gegevens
WHERE
mw_gegevens_persnr=?
AND
mw_gegevens_pass=?
AND
mw_gegevens_pass!=''
";
$statement = $connection->prepare($mw_gegevens_qry);
if($qry === false){
echo "Query error:.". $connection->error();
}else{
$statement->bind_param('is', $user, $userpassword);
$statement->execute();
$result = $statement->get_result();
$rows = $result->num_rows;
$mwgegevens = $result->fetch_assoc();