I'm not sure if I doing the connection and query 100%, but since the error I'm getting is only with the results I'm assuming I am. I don't, however, know how to process the data correctly to display it.
php:
$query = SELECT * FROM `user` WHERE `email` = 'mflem@yahoo.com' AND 'password' = 'password'
$db = new mysqli('localhost','root','','xxxxxxx') or die('unable to connect!');
if($db->connect_errno){
$message = $db->connect_error;
} else{
if($result = $db->query($query)){
$result->close();
while($row = mysqli_fetch_assoc($result)){
echo "result: " . $row['user_Id'];
}
return $result;
} else{
$message = $db->error;
return $message;
}
}
$db->close();
The error in the browser console it says.
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in C:\xampp\htdocs\apps\MyVyn\Utils\utils\servConn.php on line 14
Notice: Undefined variable: return in C:\xampp\htdocs\apps\MyVyn\Utils\utils\servConn.php on line 36
Could someone point out what I'm missing? Also are there any better ways of fetching data from you DB and displaying the results?