You have error in your php
condition, so control is not going to SQL at all
here is error :
(isset($_GET['friendquery'])
u need extra closing braces => )
So condition
should be :
if(isset($_GET['friendquery']))
/* notice extra closing ^^ braces */
In addition
$friendquery = "neva"
if(isset($_GET['friendquery']))
^^ this condition is bound to fail always if you are not fetching friendquery
from url....so, if u want to execute it in relations to $friendquery = "neva"
, then, use
if($friendquery != "")
And finally :
$row = mysqli_fetch_array($query)
is also missing from your code.
So final code should be :
if(isset($_GET['friendquery'])){ /* close extra brackets*/
$friendquery = preg_replace("/[^0-9a-zA-Z ]/", "", $_GET['friendquery']);
$sql = "SELECT * FROM users WHERE username LIKE '%$friendquery%'";
$query = mysqli_query($db_connect, $sql);
$row = mysqli_fetch_array($query) /* fetch array */
$u = $row["username"];
echo $u;
}