PHP / MySQL致命内存分配错误

时间:2014-06-04 14:35:34

标签: php mysql

我在这一行收到Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4294967296 bytes)错误:

$stmt -> bind_result($title, $author, $contents, $date, $image, $status);
mysqli / php语句的

,查询是一个select语句,从数据库中获取1行文本,是否有人知道什么是错误的?

此页面上的完整(仅限)功能:

function get_selected_article($post_type, $post_id, $post_name)
{
    $con = new mysqli("---my ip---", "---my user---", "---my pass---", "---my database---");

if (mysqli_connect_errno())
{
    echo "A problem has occurred";
    exit();
}

if ($stmt = $con -> prepare("SELECT `title`, `author`, `content`, `date`, `image`, `status` FROM ---my table--- WHERE `id` = ? AND `type` = ? ORDER BY `id` DESC"))
{
    $stmt -> bind_param("is", $post_id, $post_type); // "i" for int
    $stmt -> execute();
    $stmt -> bind_result($title, $author, $contents, $date, $image, $status);

    while ($stmt -> fetch())
    {
        echo "<table class = 'single_article_table'>";
        echo "<tr><td align='left'>".$date."</td><td align='left'>".$post_type."</td><td align='right'>".$author."</td></tr>";
        echo "<tr><td colspan='2'>".$title."</a></td></tr>";
        echo "<tr><td colspan='3'>".$content."</td></tr>";
        echo "</table>";
    }

    $stmt -> close();
}

    $con -> close();
} 

image

由于

2 个答案:

答案 0 :(得分:2)

您的content列是LONGTEXT - “一个TEXT列,最大长度为4,294,967,295或4GB(232 - 1)个字符。”来自文档:http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html

答案 1 :(得分:1)

通过将数据库中的content字段更改为mediumtext而不是longtext来解决问题。