Search the Community
Showing results for tags 'warning: mysql_fetch_array()'.
-
Hi everyone: I'm having a problem with trying to iterate thru MySQL using PHP. I use MySQL select MAX(page_id) ... to get an integer for $MAX (//biggest id record in the table) and MYSQL select MIN(page_id)... to get an integer for $MIN (//smallest id record in the table) Then I use this loop to iterate thru 100 records at a time (and avoid having too many MySQL records in memory at one time): //iterate thru 100 Mysql rows at a time and add text to each of these records (using the addtext function) for($i = $MIN; $i < $MAX; $i = $i + 100) { $x = $i; $y = $i + 100; $q = mysql_query('SELECT page_title FROM testdb.test_page WHERE (page_id >='.$x.' AND page_id < '.$y.'AND page_category = 5'); while($row = mysql_fetch_array($q)) { addtext($row['page_title'], "Additional text here"); } echo "A batch of 100 was completed!"; } I keep getting Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\testscript.php on line 47 This script keeps hanging on my Mysql statement mysql_query('SELECT page_title FROM testdb.test_page WHERE (page_id >='.$x.' AND page_id < '.$y.'AND page_category = 5'); Can someone provide advice on a better MYSQL query statement that gets 100 records at a time? i.e. select page_title from the table test_page and get 100 rows at a time and do something with these 100 records? P.S. Everything is working in my MySQL and PHP setup, so I know it's a problem with my sql query. Thanks.