I'm trying to retrieve the "id" from MYSQL table named user where the email is a certain value, but I cannot get it to work. The code I'm using is
$sql="SELECT id FROM user WHERE email=$email";
$result=$conn->query($sql);
while($row=$result->fetch_assoc()){
$id=$row["id"];
}
When I look at the erro log, it says the following:
PHP Fatal error: Call to a member function fetch_assoc() on a non-object
How can I get this to work?