cbielich
asked on
MySQL not producing the amount of records it says it pulls with php
Here is a weird one I have never seen. My code is:
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
echo $records = mysql_num_rows($result); <- this echos the correct amount of records 98191
$count = 0;
while($row = mysql_fetch_array($result) ) {
$count++;
}
echo $count; <- this produces 44 records. Even if I echo $count++ it still 44 records. What in the world would cause this?
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
echo $records = mysql_num_rows($result); <- this echos the correct amount of records 98191
$count = 0;
while($row = mysql_fetch_array($result)
$count++;
}
echo $count; <- this produces 44 records. Even if I echo $count++ it still 44 records. What in the world would cause this?
Have you tried echoing something from the fetched row in addition to just incrementing your counter?
Do you get more than 44 rows worth of data printed?
Do you get more than 44 rows worth of data printed?
ASKER
@Dave - I did that already still 44
@jay - yes I did a print_r($row); and produced 44 records
yeah Im scratching my head on this one
@jay - yes I did a print_r($row); and produced 44 records
yeah Im scratching my head on this one
What is the content of a var_dump($result) and an echo of mysql_num_rows($result) before and after your while loop?
Could $result be getting overwritten anywhere?
Could $result be getting overwritten anywhere?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok that seems to produce better results
91899 0-1-2-3-4-5-6-7-8-9-10-11- 12-13-14-1 5-16-17-18 ... 91893-91894-91895-91896-91 897-91898- 91899
... = yada yada yada :)
91899 0-1-2-3-4-5-6-7-8-9-10-11-
... = yada yada yada :)
Interesting difference.
ASKER
So what is happening?
Open in new window