tags:

views:

77

answers:

3

Hi, I have programmed one hand and tossed it on my host's server but get the error here

Fatal error: Allowed memory size of 536870912 byte exhausted (tried to allocate 4294967296 bytes)

This is my code

<?php
require 'opsatning/top.php';
?>
<!--[if IE]>
<style>
.arrow { top: 100%; };
</style>

<![endif]-->
<div id="content_indhold">
<?php
        $mysql = connect();
        $stmt = $mysql->prepare("SELECT id,billed_sti,overskrift,indhold,brugernavn,dato FROM nyheder ORDER BY id DESC LIMIT 3");
        $stmt->bind_result($id, $billed_sti, $overskrift, $indhold, $brugernavn, $dato);
        $stmt->execute();


        while($stmt->fetch()) {


?>


<div class="nyhederRamme2">

<h1><a href="vis.nyheder.php?id=<?php echo $id; ?>"><?php echo $overskrift; ?></a><span class="arrow"></span></h1>
<br />


        <a href="vis.nyheder.php?id=<?php echo $id; ?>"><img style="float:left; margin-right:5px;" src="images/nyheder/<?php echo $billed_sti; ?>" /></a>


    <a href="vis.nyheder.php?id=<?php echo $id; ?>"><?php echo substr($indhold,0,700); ?></a>


</div><!-- ramme -->


<?php
}#Lukker while
?>
</div><!-- content_indhold -->
<?php
#require 'opsatning/bund.php';
?>

Has no extraction from the database in my top.php, so do not understand it completely, it's nothing I pull out of the database

Hope knows what I'm doing wrong or could do in a different way.

Thanks in advance

A: 

The only thing I can guess is that you have some very large values in your indhold field. Could that be the case? If so, it looks like you're only showing 700 characters, so you might want to only get those characters in the query rather than getting them all and only showing some.

SELECT id,billed_sti,overskrift, SUBSTRING(indhold, 0, 700), brugernavn,dato FROM nyheder ORDER BY id DESC LIMIT 3

You also do not appear to be using the $brugernavn and $dato variables, so remove those from your query.

Scott Saunders
i change the longtext to mediumtext and now it works :D! THANKS!.
Simon
+2  A: 

Well, from that error message, it's trying to do a single allocation of exactly 4gb. How big is the record set that you are pulling from MySQL?

The thing that seems weird to me, is that the allocation amount is EXACTLY 4 GB. So unless you have a database result (or file) that's that exact size, something else sounds fishy. I mean what are the chances that it would allocate that EXACT amount of data.

You probably should post your entire code, the EXACT error message and information about the data set returned from that query...

ircmaxell
+1... I'd say the exact 4GB amount sounds like he's hitting some kind of physical limit, maybe while creating a buffer or something.
Pekka
this what i extract from the databasehttp://pastebin.com/Q0Ep0yGMThis is my news scripthttp://pastebin.com/t3gPknXFi have comment out all the include so its only the 1 query and while doingThis is my error i getFatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4294967296 bytes) in /home/public_html/test/nyheder.php on line 16on line 16 is this:$stmt->bind_result($id, $billed_sti, $overskrift, $indhold, $brugernavn, $dato);i help you can help!
Simon
You should call `bind_result` after `execute`, not before... http://php.net/manual/en/mysqli-stmt.bind-result.php
ircmaxell
+1  A: 

Is one of your columns a LONGBLOB or LONGTEXT?

PHP tries to allocate enough memory to hold the maximum size of that column (4,294,967,296 bytes). See here (note the last post on the page):

http://bugs.php.net/bug.php?id=51386

If that's the case, changing the column to a MEDIUMTEXT or MEDIUMBLOB, or something smaller if you can get away with it.

Mike