Im getting this error when I call my php file. I want to fetch the row returned by the query. It stores basic info like name and surname. I expected to resultValue to have the following structure after the second commented line but I get an error instead:
$returnValue["name"] = "jack"
$returnValue["surname"] = "london"
I know there is similar questions and Im sure I looked into all of them but I still have the same problem. Im sure that my procedure works because I ran it on the server and It returned the row I expected.
<?php
require("Connection.php");
$userName = htmlentities($_POST['userName']);
$password = htmlentities($_POST['password']);
$conn = new mysqli(Connection::$dbhost,Connection::$dbuser,Connection::$dbpass,Connection::$dbname);
$returnValue = array();
try{
$stmt = $conn->prepare("CALL login(?,?,@res);");
//stored procedure returns a row containing user information
$stmt->bind_param('ss', $userName, $password);
$res = $stmt->execute();
$returnValue = $res->fetch_array(MYSQLI_ASSOC);//Error on this line
}catch(Exception $e){
$returnValue["result"] = 0;
}
echo json_encode($returnValue);
$conn->close();
?>