dongwen3410 2015-10-06 09:34
浏览 53

AJAX和PHP崩溃服务器

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.

  • 写回答

1条回答 默认 最新

  • dou7466 2015-10-06 10:08
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题