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; ?&g开发者_开发知识库t;" /></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
Even if this is old, for future reference:
Always call mysqli->store_result()
before you call mysqli->bind_result()
.
PHP then knows how much data will be received and only allocates that much memory instead of allocating the maximum of what could be possible. This would be 4 GB with LONGTEXT, LONGBLOB.
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...
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.
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.
精彩评论