简体   繁体   中英

PHP 7.1 Fatal error : Allowed memory size of 268435456 bytes exhausted

PHP version 7.1 I am trying to create a page where any user can upload an image, their name, comment, and their email. On the webpage, only the user name, comment and the image they uploaded will show up. I am not sure if this will help with anything but I am using Hostgator mysql database to store all the data. In previous questions (on this website - PHP Warning mysqli_fetch_assoc() ) I had errors regarding the fetch and get statements. However one of the solutions solved that issue but sadly now I get a warning saying:

Fatal error:Allowed memory size of 268435456 bytes exhausted (tried to allocate 4294967296 bytes) in gallery.php on line 45

I have looked another post on this website regarding this same issue and I have been trying to follow the steps but was not successful. I would appreciate it if someone can guide me through this issue. Thanks in advance.

The codes it is referring to:

<div class="gallery-container">
<?php
include_once 'includes/dbh.inc.php';

$sql = "SELECT imgFullNameGallery, titleGallery, descGallery FROM gallery ORDER BY orderGallery 
DESC;";

$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL statement failed!";
} else {

mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $imgFullNameGallery, $titleGallery, $descGallery);


while (mysqli_stmt_fetch($stmt)) {
echo '<a href="#">
<div style="background-image: url(img/gallery/'.$imgFullNameGallery.');"></div>
<h3>'.$titleGallery.'</h3>
<p>'.$descGallery.'</p>
</a>';
}
}
mysqli_stmt_close($stmt);
mysqli_close($link);
?>
</div>

尝试在 php.ini 中使用此行ini_set('memory_limit', '256M')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM