I need to send push notification to many users. I have saved their push notification key in my database. I am trying to send it in a loop but it only sends first push notification and after that it gives following error:
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/theacademicpoint/public_html/tapadmin/webservices/sendPostNotification.php on line 39
Following is my code for calling the push notification script:
$sql = "SELECT distinct users.userid, firstname, lastname, userType, title, device, pushkey FROM student_course, users where users.userid!=".$userid." and users.userid= student_course.userid and ucid in (".implode(',',$arrUserCourse).") ORDER BY firstname";
$result = mysqli_query($con,$sql);
while($row = $result->fetch_assoc())
{
$device = $row["device"];
echo $row["firstname"];
if($device=="ios"){
$deviceToken = $row["pushkey"];
$message = "New Post added from ".$user;
include('push.php');
}
}
}
If I comment out call to php script(push.php) the loop runs completely without any error. But if I uncomment it like above, it gives error as mentioned above. Though the loop still executes completely.
Regards
Pankaj