I have a simple page with a DB table that is updated every second using a AJAX POST request to a PHP page. After 40/50 minutes the server crashes and it is out of service for 1 hour. Is it a known issue?
function runAjax(){
var filename = "readDB.php";
$.ajax({
type: "POST",
url: filename,
data: abc_params,
success: function(msg){
processResponse(msg);
}
});
}
function processResponse(txt){
dosomething(txt);
setTimeout("runAjax()",1000);
}
setTimeout("runAjax()",1000);
readDB.php simply returns a string with all fields of 1 row of 1 table of the DB
UPDATE: I tried also with a "readDB.php" page like this:
<?echo "OK";?>
After 2 hours the site php pages give error 500 but only after 1 minute the site works correctly again.
Here may be problem with mysql connection limit, So please follow like :
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
using "mysql_close" it will terminate connection