I'm currently switching from mysql to mysqli and I'm getting errors when I'm converting this function which was working under mysql.
include("config.php");
function getUsername($uid){
$sql = "SELECT username FROM users WHERE id='".$uid."' LIMIT 1";
$result = mysqli_query($conn,$sql) or die(mysqli_error(""));
$row = mysqli_fetch_assoc($result);
return $row['username'];
}
Errors:
Notice: Undefined variable: conn
Warning: mysqli_query() expects parameter 1 to be mysqli, null given in
Warning: mysqli_error() expects parameter 1 to be mysqli, string given in
How should it be written?