This is my code:
$con = mysqli_connect($databasehost,$dbname,$dbpassword) or die(mysql_error());
mysqli_select_db($con, $dbname) or die(mysql_error());
mysqli_query($con,"SET CHARACTER SET utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con,$query);
if (mysql_errno()) {
    header("HTTP/1.1 500 Internal Server Error");
    echo $query.'\n';
    echo mysql_error();
}
else
{
    $rows = array();
    while($row = mysql_fetch_assoc($sth)){
        $rows[] = $r;
    }
    print json_encode($rows);
}
What's the problem?
This is the error:
[19-Jan-2018 09:17:39 UTC] PHP Warning:  mysql_fetch_assoc() expects parameter 1 to be resource on line 22
 
     
    