在num_rows的组合中,bind_param en fetch(_assoc)。
我在$ salt = $ saltuitkomst [' salt'];
中得不到任何结果$ user = 195
$ rows正在给出数字1
没有错误消息
$saltqry = "SELECT
salt,
mw_gegevens_groep
FROM
mw_gegevens
WHERE
mw_gegevens_persnr = ?
";
if(!$statement = $connection->prepare($saltqry))
{
echo "Query error:.". $connection->error();
} else {
if(!$statement->bind_param('i', $user)){
echo "bind param did not work";
}else{
$statement->execute();
$statement->store_result();
$rows = $statement->num_rows;
$saltuitkomst = $statement->fetch();
}
}
if($rows == 0) {
$salt='';
} else {
$salt = $saltuitkomst['salt'];
echo '-'.$salt.'-';
}
答案 0 :(得分:2)
$saltqry = "SELECT
salt,
mw_gegevens_groep
FROM
mw_gegevens
WHERE
mw_gegevens_persnr = ?
";
if(!$statement = $connection->prepare($saltqry))
{
echo "Query error:.". $connection->error();
} else {
if(!$statement->bind_param('i', $user)){
echo "bind param did not work";
}else{
$statement->execute();
$statement->store_result();
$statement->bind_result($salt, $group);
$saltuitkomst = $statement->fetch();
if($saltuitkomst) {
echo '-'.$salt.'-';
} else {
$salt='';
}
$statement->close();
}
}