PHP MySQLi timeout


PHP MySQLi timeout

今天我创建了一个网站。但我有点。。卡住了。

我是这样做的:

function getRank($rank)
{
    if ($stmt = $GLOBALS['mysqli']->prepare('SELECT * FROM users_ranks WHERE id = ?     LIMIT 1'))
    {   
        $stmt->bind_param('i', $rank);
        $stmt->execute();
        $row = $stmt->get_result()->fetch_assoc();
        return $row;
    }
}

我的数据库是正确的。在我的方法中,我使用:

<?php 
    $att = array();
    $color = '';
    $font = '';
    $name = '';
while ($res = getRank($_SESSION['USER']['role']))
{
    $color = $res['color'];
    $font = $res['font'];
    $name = $res['name'];
}
echo '<text style="font-family: ' . $name . '; color: ' . $color . ';">';

echo $_SESSION['USERNAME'];
echo '</text>';
?>

当它运行代码时,我总是收到这样的错误:

Fatal error: Maximum execution time of 30 seconds exceeded in C:'xampp_new'htdocs'iondelt'global.php on line 80

线路:

$row = $stmt->get_result()->fetch_assoc();

我不是mysqli大师,请帮帮我:)

while ($res = getRank($_SESSION['USER']['role']))

这看起来像是一个无限循环。$res怎么会为了退出循环而变成false?

get_result()是在PHP 5.4.0中引入的,需要mysqlnd。需要吗?尝试

$row = $stmt->fetch_assoc();