I've got a php script which runs a sql query that's passed to it from some javascript code on an html page. The php script works fine until I call it more than once in quick succession (from the same button click), in this case the server only processes the first call to the php script, on the second call it gives an error 500 internal server error. Is it possible that, when the server receives the second call to the php script that the server has not completely finished processing the first call and thats why it is giving the error? If so is there a way to prevent this? I've included the php script below. Thanks for your time.
<?php
$servername = "localhost";
$username = "f3645807";
$password = "MD5!a8aa";
$dbname = "f3645807_wildlife";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$qry = $_REQUEST["qry"];
$sql = $qry;
$result = $conn->query($sql);
$locArray = array();
if ($result->num_rows > 0)
/*if query pulls back at least 1 row run this bit*/
{
while($row=$result->fetch_assoc()) {
// echo json_encode($row["Location_Name"]);
$locArray[] = $row;
}
echo json_encode($locArray);
}
?>