Jump to content

MySql not selecting last row in set [Solved]


Pezzoni

Recommended Posts

Like the title says.

For example, if I have n rows in a database, then run 'SELECT *' on it, then n-1 rows are always returned (the newest one is left off). This is happening at the most basic level of the result returned by mysql_query, so I really have no idea what is wrong. Does anyone have any suggestions?

Thanks,

Dan
For these types of problems, it's always recommended that you post the exact code so members of this forum can help you better.

However, it's been my experience that it's usually attributed to a coding logic mistake (as opposed to a SQL query problem).

Common mistakes:

Running a fetch command before doing fetches in a while loop, causing the first row not to get processed.

Exiting a while loop that's fetching data prematurely (like using break).

Relying on a counter (for number of rows in the result) and the counter is manipulated erroneously.

Using LIMIT and the values aren't correct.

Not quite a logic error, but a bit of copy&paste related stupidity on my behalf. I had a mysql_fetch_array() on it's own, in addition to the one I used to build an index of the results. Which shouldn't have been there.

Thanks for the help, and sorry for the dumb-ass mistake... There goes another 3 hours of my life! :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.