我正在尝试运行一个 php 脚本,基本上说,当我的 MySQL 数据库中的两个单元格为空(t_trailerarrival 和 t_endsort)时,做一些事情。
我的代码如下:
<?php
// Start Session, include authentication and dBConnection script
session_start();
include 'dbcon.php';
include 'sql_actuals.php';
$current_time = date("G");
while($query9_row['a_trailerarrival'] == NULL && $query10_row['a_endsort'] == NULL) {
echo "Trailer Arrival";
}
$queryx_row['abc'] 都在包含在该脚本中的 sql_actuals 脚本中。
出于某种原因,每次我运行此脚本时 - 我的浏览器都不会加载结果(只会永远加载),然后我在 windows azure 的网站似乎崩溃并需要几分钟才能重新启动。
有人可以告诉我我的脚本是否有明显的错误吗?或指出可能的问题。
非常感谢。
仅供引用,我尝试添加一行 sleep(1);
以便在必须再次运行程序之前给服务器延迟运行,但没有成功。
最佳答案
您永远不会关闭 while 循环。
while($query9_row['a_trailerarrival'] == NULL && $query10_row['a_endsort'] == NULL) {
echo "Trailer Arrival";
}
在 while 语句中不修改 while 条件,一旦开始,就永远不会停止。因此挂起脚本和服务器。
关于php - 在 PHP while 循环期间页面不会加载并且服务器崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18702135/