How do I return an error from the following query if there is no email address found in the database that corresponds to the variable $check_email. As it stands I can put any gobbledygook into the textfield on my site and it still retrieves a $result
. (Have escaped the string. Moving onto prepared statements in time so bear with me on that point).
I hoped to have the error message that you see here.
$query = "SELECT lastimage FROM scorers WHERE email = '{$check_email}'";
$result = mysqli_query($con, $query);
// Test if there was a query error
if (!$result)
{
die("We cannot find you in the database, please start again!");
}
while($row = mysqli_fetch_row($result))
{
// output data from each row
$image_number= $row[0];
}