Saturday, September 21, 2019

PHP/MySQL Fatal memory allocation error



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 "";
echo "";
echo "";
echo "";
echo "
".$date."".$post_type."".$author."
".$title."
".$content."
";
}

$stmt -> close();
}


$con -> close();
}


image



Thanks


Answer



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


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...