Hi,
mit nachfolgendem SELECT will ich prüfen, ob eine bestimmte IP bereits in der MySQL-DB gespeichert ist.
Ich bekomme allerdings immer $anzahl = 1 zurückgeliefert und damit TRUE, obwohl die IP-Adresse noch nicht in der Datenbank gespeichert ist...
Wo liegt der Fehler?
mit nachfolgendem SELECT will ich prüfen, ob eine bestimmte IP bereits in der MySQL-DB gespeichert ist.
Ich bekomme allerdings immer $anzahl = 1 zurückgeliefert und damit TRUE, obwohl die IP-Adresse noch nicht in der Datenbank gespeichert ist...
Wo liegt der Fehler?
PHP-Code:
function ipcheck ($ip, $mysqli){
if($stmt = $mysqli->prepare(" SELECT MAX(id), user_agent
FROM stat
WHERE ip = ? ")){
$stmt->bind_param("s", $ip);
$stmt->execute();
$stmt->store_result();
$anzahl = $stmt->num_rows;
$stmt->bind_result($id, $user_agent);
echo "Anzahl ist: " . $anzahl . "<br>\n";
if ($anzahl != 0){
return TRUE;
} else {
return FALSE;
}
}
}

Kommentar