MySQL query is not returning the expected Boolean value
Web Development
1
Posts
1
Posters
0
Views
1
Watching
-
Hello everyone I have to come up with a MySQL query that can fetch a single match by name and phone number. To that end, I wrote a query below in my query functions script:
$sql = 'SELECT * FROM users ';
$sql .= 'WHERE name="' .db_escape($db, $user['name']) . '" AND phoneno="' . db_escape($db, $user['phoneno']) . '"';
$sql .= 'LIMIT 1';
$result = mysqli_query($db, $sql);
confirm_result_set($result);
$row = mysqli_fetch_assoc($result);
if(!empty($row)) {
return true;
} else {
return false;
}However, this query will not return true when a match is found. Please help me work out how this query can be corrected to meet the goal. I'm looking forward to receiving hints/suggestions. Thanks for reading.