页面在提交页面时加载了很长时间

时间:2016-07-23 16:56:28

标签: php mysql mysqli pdo

在经历了几个小时的挫折之后,才得到这段代码。我知道我混合了MySQLI和PDO,但这只是为了让一切正常 - 我会在发布之前将所有内容转换为PDO。这是我的火力部门的调度网页。

出于某种原因,当我点击"提交",带我到第二页运行这些命令时,它会在运行命令之前加载大约2分钟。

以下是回复:

array(2){[0] => string(4)" 0004" [" ID"] => string(4)" 0004" } 致命错误:第765行/home/rhapidfyre/public_html/sasd/supervisor.php中允许的内存大小为67108864字节(试图分配608字节)

第765行是底层的HTML表单代码,用于" supervisor.php"

if($_GET['call'] == "close")
{
    if($_GET['callid'])
    {
        if($_GET['page'] == 'two')
        {
            $callid = $_GET['callid'];
            $closing = $_POST['closing'];
            $query = "SELECT id FROM engaged WHERE callnum = '$callid'";
            $getunits = $link->query($query);
            $unitsrow = $getunits->fetch_array(MYSQLI_BOTH);

            var_dump($unitsrow);

            $doit = $db->prepare("UPDATE incidents SET closing = :closing, closer = :myname, active = 0, archive = 1 WHERE id = :callid");
            $doit->bindParam(':callid',$callid);
            $doit->bindParam(':myname',$myname);
            $doit->bindParam(':closing',$closing);
            $doit->execute();

            $doita = $db->prepare("DELETE FROM engaged WHERE callnum = :callid");
            $doita->bindParam(':callid',$callid);
            $doita->execute();

            for($i = 0;$i < count($unitsrow);$i++) {
                $doitb = $db->prepare("UPDATE logins SET assigned = '0' WHERE id = :unitnum");
                $doitb->bindParam(':unitnum',$unitsrow[$i]);
                $doitb->execute();
            }

            echo '<script type="text/javascript">window.location = "supervisor.php?finished=closecall"</script>';
        }
        else
        {
            $callid = $_GET['callid'];
            $prep = $db->prepare("SELECT * FROM incidents WHERE id = :callid");
            $prep->bindParam(':callid',$callid);
            $prep->execute();
            $prepresult = $prep->fetch();
            ?>
            <form action="supervisor.php?do=func&call=close&callid=<?echo $_GET['callid'];?>&page=two" method="POST">
                <font color="#FF0">You are closing call #: </font><font color="#FFF"><strong><?echo $_GET['callid'];?></font><br />
                <font color="#FF0">Incident Type: </font><font color="#FFF"><strong><?echo $prepresult['type'];?></font><br />
                <font color="#FF0">Incident Loc : </font><font color="#FFF"><strong><?echo $prepresult['location'];?></font><br /><br />
                <font color="#FF0">CLOSING NOTES:</font><br/>
                <textarea rows="6" cols="60" name="closing" /></textarea><br />
                <input type="submit" value="SUBMIT!">
            </form>
            <?
        }
    }
    else
    {
        $callzactive = mysqli_query($link, "SELECT id,priority,type,location FROM incidents WHERE active = 1");
        ?>
        <font color="#FF0"><strong>SELECT CALL NUMBER</strong></font><br />
        <select onChange="window.location.href=this.value">
        <option>SELECT</option><?
        while($callsactive = mysqli_fetch_array($callzactive))
        {
            ?>
            <option value="supervisor.php?do=func&call=close&callid=<?echo $callsactive['id'];?>"><?echo "#".$callsactive['id']." (".$callsactive['priority'].") ".$callsactive['type']." @ ".$callsactive['location'];?></option>
            <?
        }
        ?></select><?
    }
}

1 个答案:

答案 0 :(得分:-1)

尝试为了测试删除for循环中的更新查询

M

一般而言,不是速度方面的解决方案。在for循环之前准备语句。与另一个问题中的answer一样。