mpi Posted November 25, 2017 Share Posted November 25, 2017 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 ? Quote Link to comment Share on other sites More sharing options...
requinix Posted November 25, 2017 Share Posted November 25, 2017 How many results are you getting from that query? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted November 25, 2017 Share Posted November 25, 2017 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.