I have developed a very basic php based webservice to communicate with my android application. This is working fine and I am able to get the data, but when I simultaneously try to access the service from multiple devices or even from browser, only one of them gets the result and other goes on to loading, while the successful one is still able to get the result out of it. Kindly suggest me how can I overcome this problem.
PHP Code :
<?php
$con=mysqli_connect("host","username","pass","DB");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT * FROM ScoreBoard a inner join Groups b ON a.User_ID=b.ID ORDER By score DESC";
$return_arr = array();
if ($result=mysqli_query($con,$sql))
{
// Fetch one and one row
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
$rows[] = $row;
}
// Free result set
mysqli_free_result($result);
}
echo json_encode($rows);
mysqli_close($con);
?>