Can someone tell me what is the problem with this code? I've been trying to get the values from my database for hours and the results are always null.. Except for the username and password.
<?php
$con = mysqli_connect("aaaaa", "bbbbb", "cccccc", "ddddd");
$email = $_POST["email"];
$password = $_POST["password"];
$statement = mysqli_prepare($con, "SELECT * FROM table WHERE email = ? AND password = ?");
mysqli_stmt_bind_param($statement, "ss", $email, $password);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $id, $full_name, $email, $password, $distance, $average_rating, $home_address, $work_address);
$response = array();
$response["success"] = false;
while(mysqli_stmt_fetch($statement)){
$response["success"] = true;
$response["full_name"] = $full_name;
$response["email"] = $email;
$response["password"] = $password;
$response["distance"] = $distance;
$response["average_rating"] = $average_rating;
$response["home_address"] = $home_address;
$response["work_address"] = $work_address;
}
echo json_encode($response);
?>
The problem seems to be in the mysqli_stmt_bind_result line, but I can't figure it out. The order of the variables is correct. I have a connection with the database and everything is OK, but the results are null.
Here's the JSON result:
{"success":true,"full_name":null,"email":"aaaaaaaaa","password":"bbbbbbb","distance":null,"average_rating":null,"home_address":null,"work_address":null}