Jump to content

Fatal error: Out of memory (allocated 408944640) (tried to allocate 805306376 bytes)


mpi

Recommended Posts

Hi 

I wrote this code in notepad ++ :

<?php

 ini_set("memory_limit",-1);
 $myArray = Array();

 $connection  = mysqli_connect("localhost","my_user","my_password","my_db");
 $result = mysqli_query($connection, "SELECT * FROM tablename");
  
 while(($row = mysqli_num_rows($result))== null){
array_push($myArray,$row);
 }

 echo json_encode($myArray);
 mysqli_close($connection ); 

?>

And run it with wamp localhost . Then I got this error in my browser :  

Fatal error: Out of memory (allocated 408944640) (tried to allocate 805306376 bytes) in D:\...\page1.php on line 10

What's problem ? Can anybody says ? 

 

Link to comment
Share on other sites

What the h... is this line doing for you?

while(($row = mysqli_num_rows($result))== null)
You are doing a loop using the number of rows and comparing it to null and assigning that test to $row? So apparently your query is returning nothing (0) and that gives you a $row value of 0 which is equal to null and so you loop forever.

 

Again - what do you THINK you are doing here?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.