Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:33:32+00:00 2026-06-09T05:33:32+00:00

I have a php script that loads data from a database. The table I

  • 0

I have a php script that loads data from a database.
The table I am loading the data from is 50mb big, and the current php memory settings allow for 128mb – still I get the error message

Allowed memory size of 134217728 bytes exhausted (tried to allocate 6 bytes)

Some research has led me to changing the following in php.ini:

memory_limit = 128M

I changed it to -1, which according to the documentation will set it to infinite. To no avail.

Not only does it not makes sense that even if the query returned all of the 50mb, it should not complain since the limit is set to 128mb – strangely, the query I run does not even need much memory: when I echo it out and run it directly in the database, it only returns three rows. The query looks as follows:

SELECT * FROM table WHERE foreign_id=1

Does anyone know how to fix that problem? I would like to set the memory limit to infinite.

EDIT 1

First of all – does it matter that I run the script from my terminal, not from my browser?

Second, here is the php code:

//Connect to database
$user="root";
$databasePassword="password";
$host="127.0.0.1";
$database="primarydata";
$identifier=mysql_connect($host,$user,$databasePassword,true);
$db1=mysql_select_db($database);

//Select * from first table
$query="SELECT id,name,city,country FROM table1 WHERE id>=1 ORDER BY id ASC";
$result=mysql_query($query);
$datas=array();
while($row=mysql_fetch_object($result)) $datas[]=(object) $row;

//Loop through artists
for($i=0;$i<sizeof($datas);$i++){
    for($j=$i+1;$j<sizeof($datas);$j++){
        //This is where the problem occurs
        $query="SELECT * FROM table2 WHERE data_id=".$datas[$i]->id;
    }
}

Third, do I have to use “–enable-memory-limit'”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:33:33+00:00Added an answer on June 9, 2026 at 5:33 am

    Try:

    ini_set('memory_limit','-1')
    

    When I insert millions of entries into a database (samples), then I had the same problem as you. This one helped.

    EDIT: to add, using this is not recommended (only e.g. on localhost for examples as I gave you, entering tons of sample data into a database, etc.) This answer was posted before you posted your php code…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that inserts data from an Android app into a
I have a PHP script that works by calling items from a database based
I have a server with a PHP script that pulls data from a source
I have an ajax script, in the main index.php page, that fetches data from
I have a php script that grabs links from another website. I am storing
I have a php script that backup my table in .sql format and I
I have a jQuery AJAX data grid that loads a list of elements from
I have a PHP script that loads XML content dynamically: require_once 'directory/directory/'; $nice= '1149632';
I have to request data for a JS-script from a MySQL database (based upon
I have php script that creates a temporary watermark image for users that are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.