I'm making a email confirmation page but when the user clicks the link in the email it bring them to the accept page. When the page loads however it returns with this error.
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in /home/gener105/public_html/email_confirm.php on line 15
<?php
include 'includes/dbh.php';
$username = $_GET['username'];
$code =$_GET['code'];
$sql= "SELECT * FROM users WHERE username='$username'";
$result= mysqli_query($conn, $sql);
if (! $result){
throw new My_Db_Exception('Database error: ' . mysql_error());
}
while($row = mysql_fetch_assoc($result)) {
$db_code = $row['confirm_code'];
}
if($code == $db_code) {
$sql2 = "UPDATE users SET confirmed=1 WHERE username='$username'";
$result2 = mysqli_query($conn, $sql2);
$sql3 = "UPDATE users SET confirm_code=0 WHERE username='$username'";
$result3 = mysqli_query($conn, $sql3);
echo "It worked!";
} else {
echo "Error: Username and code dont match!";
}
?>
I know its talking about the while statement but I been researched what its talking about and I'm confused I thought the $result variable is what should be the parameter.