I know this is a internet blog rather than a coders blog, but after a while of seeing this problem and not finding any help with it I thought I would post here about some success I had.
Over the last few months I have had a few sites come up with this problem:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in/dir/page.php line 123
The problem is that the problem seemed intermittent with no similarity or some thread I could link to another.
Most it was about getting numbers of rows of records for paginating database results.
Yesterday, I had a similar problem with a third party product which I had purchased on behalf of a client and lodged a ticket.
I got a quick response that this was an issue with the version we were running and MySQL 5
In this case it seems that a reserved word was used in the database for one of the column names and when this was used in the database queries, it failed giving the above error.
After a few code replaces it worked great.
Big thanks to the support team for their quick response.
However, here are the things learnt from this:
- Reserved words are a bit of a pain as version 5 of MySQL added some more that were plain language (this one was the word \”out\”
- The error mentioned above is a failure of the query to generate a valid result, not that the result is empty.
- Running the query in phpmyAdmin or similar can shed extra light into what is failing
So endeth the coders rant, normal service now resumes 🙂
Let me know if you have any similar issues