Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given code example

Example 1: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in

mysqli_fetch_array($result)

Example 2: mysqli_fetch_array() expects parameter 1 to be mysqli_result

$sql = "select * from privinsi";
$result = mysqli_query($connection,$sql);
while($r = mysqli_fetch_array($result))
{
    // your code here
}

Example 3: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in

mysqli_fetch_array($query)