im trying to get some data from my DB.
My problem is that i get null pointer on my array when i try to get the data.
When i run my sql command in phpmyadmin i get good results.
I also checked with echo that $ids[$i] isnt null.
The error message:
Warning: array_push() expects parameter 1 to be array, null given
Thanks for helping.
This is my code:
while($i < $size)
{
$mysqli = new mysqli(****);
$sql = "SELECT workout_name, user, likes, dislikes, date FROM workouts_wall WHERE id_for_wall = ? ";
$stmt = $mysqli->prepare($sql) or trigger_error($mysqli->error."[$sql]");
$stmt->bind_param('i', $ids[$i]);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($workout_name, $user, $likes, $dislikes, $date);
if($stmt->fetch())
{
// temp user array
$workouts = array();
$workouts["workout_name"] = $workout_name;
$workouts["picture"] = getPicture($user);
$workouts["user"] = $user;
$workouts["likes"] = $likes;
$workouts["dislikes"] = $dislikes;
$workouts["date"] = $date;
// push single product into final response array
array_push($response["workouts"], $workouts);
}
$i++;
}