I have connected to database link below
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "db";
$sql = new mysqli($db_host,$db_username,$db_password,$db_name);
And I refered to it on a different page like:
function user_exists($username){
$username = sanitize($username);
$query_user = $sql->query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
return (mysqli_result($query_run,0)==1)? true:false;
}
But I still receive:
undefined variable sql,
What am I missing?