Friday, 23 September 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...