I have a php webpage which finds all the users in 1km radius of latitude and longitude provided as input. The lat and long are given as input to database and it generates a list of 10 users as output. I want to send a message to each user of this generated list after retrieving their device ids. But i am not able to do so. Please help
$sql = "SELECT number, userID,
( 6371 * acos( cos( radians(19.143) )
* cos( radians( latitude ) )
* cos( radians( longitude )
- radians(72.831) )
+ sin( radians(19.143) )
* sin( radians( latitude ) )
)
) AS distance
FROM users
WHERE device = 'android'
HAVING distance < 2
ORDER BY distance;";
$result = mysql_query($sql,$link);
if (mysql_num_rows($result) != 0)
{
while($row = mysql_fetch_assoc($result))
{
//send notification code
}
}
When i execute this code, i get an error
mysql_fetch_assoc() expects parameter 1 to be resource, string given in..
Please help. Thanks in advance.