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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.