0

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>
brazencore
  • 17
  • 7

1 Answers1

-1

try with this line ini_set('memory_limit', '256M') in your php.ini

JulianFranco
  • 1
  • 1
  • 1
  • 3
    With **tried to allocate 4294967296 bytes** that amount of 256M would not help, already 268435456 bytes exausted. – Tom Kuschel Jan 13 '20 at 02:30
  • when I put in the code Julian Franco provided the error message went away but now nothing is showing up like no error message nor the actual web content. Thank you though – brazencore Jan 13 '20 at 02:35
  • That's not the correct syntax for php.ini. Inserting this line will cause PHP and/or Apache to fail to start. – amphetamachine Sep 27 '21 at 19:37