SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict adam2003w's Avatar
    Join Date
    Mar 2004
    Location
    colorado
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL: mysql_fetch_assoc dies out before retrieving all records

    I have a mysql table (with 8,316 rows) I'm trying to output to an array in PHP, but it times out (at around 8,058 to 8,060 rows). Anyone know how to resolve this:

    Here's my environment:
    PHP 5.3.3, Linux host, MySQL 5.1.61

    Here's my code:
    PHP Code:
    mysql_select_db($database$connection);
    $query_rs_data sprintf(" SELECT * FROM my_table ");
    $rs_data mysql_query($query_rs_data$connection) or die(mysql_error());
    $row_rs_data mysql_fetch_assoc($rs_data);
    $totalRows_rs_data mysql_num_rows($rs_data);

    echo 
    $totalRows_rs_data;

    $my_array = array();
    $count 0;
    do {
        
    $count $count 1;
        echo 
    $count "<br/>";
        
    $my_array[$row_rs_data['id']] = $row_rs_data;
    } while (
    $row_rs_data mysql_fetch_assoc($rs_data)); 

  2. #2
    SitePoint Addict adam2003w's Avatar
    Join Date
    Mar 2004
    Location
    colorado
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind.

    Found out is was a "Fatal Error: Allowed memory size of X bytes exhausted" error. So I just increased the php.ini memory_limit.

    Problem fixed.

  3. #3
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,079
    Mentioned
    53 Post(s)
    Tagged
    0 Thread(s)
    Try reducing the number of columns returned if possible when dealing with recordsets of this size. Also, PEAR has a streaming tool for large recordsets you may want to look into.

  4. #4
    SitePoint Addict adam2003w's Avatar
    Join Date
    Mar 2004
    Location
    colorado
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips. If the problem comes up again, I'll look into them.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •