I have got a problem with testing out if a string exists in my database!
This is what I've got so far:
$db = mysqli_connect("localhost", "database", "secret", "user");
if(!$db)
{
exit("Error: ".mysqli_connect_error());
}
$search = 'SELECT * FROM table WHERE ip = $client_ip';
$result = mysqli_query($db, $search);
while($row = mysqli_fetch_object($result)) {
if (isset($row->blocked)) {
echo 'You are blocked!';
} else {
echo 'You are not blocked!';
}
But this won't work for me. $client_ip is defined correctly before.
mysqli_num_rows($result)to see number of return result before going ahead$resultis false, as a failed query will return false bymysqli_query()