I use below php code to send results of MYSQL databse search to AJAX requests...
$query = $db->query("SELECT name FROM search WHERE qurl = '" . $queryString . "'");
if($query) {
while ($result = $query ->fetch_object()) {
echo $result->name;
}
} else { echo 'no results found'; }
but I never get no results found message even there is no results, all I get if there is no result, two empty spaces - I found that using alert(data.length) in AJAX page, result was 2 which means php output has two empty spaces when there is no results...
but when there are results it works fine...
any way of removing these two spaces or why Im not getting no results found message?
$queryStringis properly sanitized, because if it isn't, you're missing the whole point, and should be using prepared statements.