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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.