0
I want to save the result of a query in $_SESSION
, but when I try to retrieve the $_SESSION
, wrong
"Couldn’t fetch mysqli_result".
Note: I use the session_start()
. Follows the code:
Query mysql:
$user_types = $mysqli->query("SELECT tipo from tipo_usuario WHERE usuario = '$user_id' ORDER BY tipo");
Putting the result in $_SESSION:
$_SESSION['user_types'] = $user_types;
When I try to retrieve the query by $_SESSION
, here the error happens:
while($row = $_SESSION['user_types']->fetch_array())
I believe that it is better to keep the specified value than Resource (return of
query()
). Basically what you should guard is the return offetch_array()
– rray