Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP/MySQL Fatal memory allocation error

Tags:

php

mysql

Im getting the Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4294967296 bytes) error on this line:

$stmt -> bind_result($title, $author, $contents, $date, $image, $status);

of a mysqli/php statement, the query is a select statement that gets 1 row of text from a database, does anyone know whats gone wrong?

Full (and only) function on this page:

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

Thanks

like image 563
GrizzlyRawrz Avatar asked Oct 20 '22 07:10

GrizzlyRawrz


1 Answers

Your content column is LONGTEXT - "A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 – 1) characters." from the docs: http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html

like image 146
Scott Saunders Avatar answered Oct 23 '22 03:10

Scott Saunders