duancheng6500 2013-03-10 11:07
浏览 75
已采纳

间歇性地获得“最长执行时间”错误

I am facing this problem, firstly I would like to say that I am very new to PHP and MySQL.

Fatal error: Maximum execution time of 30 seconds exceeded in 
.........................\cdn\wished.php on line 3

I don't know what is wrong in line 3, its giving error only sometimes. Here's my code:

<?php
//wished.php
$CheckQuery = mysql_query("SELECT * FROM users WHERE ownerid='$user->id'");
$wished = 0;
while($row = mysql_fetch_assoc($CheckQuery))
{
//  echo $row['fname']."<br/>";
    $wished++;
}
echo $wished;
?>

It was perfect when I run this in localhost with XAMPP. As soon as I hosted my app on my domain and used their database, it start getting error.

thanks every one :)

  • 写回答

1条回答 默认 最新

  • duanbeng8872 2013-03-10 11:22
    关注

    The issue is that the SQL query is taking too long, and your production PHP configuration has the PHP script time limit set too low.

    At the beginning of the script you can add more time to the PHP time limit:

    http://php.net/manual/en/function.set-time-limit.php

    set_time_limit(60);

    for example to add 30 more seconds (or use 0 to let the PHP script continue running).

    If your production database is different than your development DB (and I'm assuming production has way more data) then it might be a really expensive call to get everything from the user table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器