I am trying to get all my results from a database into and array:
$sql = "SELECT * FROM posts WHERE user = ?";
if($stmt = mysqli_prepare($link, $sql)){
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_username_int);
// Set parameters
$param_username_int = $user;
// Attempt to execute the prepared statement
if(mysqli_stmt_execute($stmt)){
mysqli_stmt_store_result($stmt);
mysqli_fetch_assoc($stmt);
}
// Close statement
mysqli_stmt_close($stmt);
}
When I try to fetch the results with this line:
mysqli_fetch_assoc($stmt);
I am expecting to get results into an array.
I get this error:
mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, object given