5

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

7
  • how many rows are you expecting! Commented Jun 4, 2014 at 14:41
  • 1
    trying to allocate 4gig? that's a bit much... What exactly is in this image field? a blob, or just a url to an on-disk file? Commented Jun 4, 2014 at 14:43
  • What is the format of the data you're trying to retreive? Are the image a blob? Commented Jun 4, 2014 at 14:43
  • @GrizzlyRawrz - can you try without the image? Commented Jun 4, 2014 at 14:45
  • @Marc B trying to get 1 field, and the image field is a VARCHAR link Commented Jun 4, 2014 at 14:46

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

Fix the problem by changing the content field in the database to mediumtextrather than longtext.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.