|
Posted by Richard Lynch on 01/06/05 23:10
Wil Hitchman wrote:
> I get the following error
>
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource in /home/wilmail/public_html/elblog.php on line 7
> &n=& //error ends here
>
> with the following bit of code
>
> $qResult = mysql_query ("SELECT * FROM blog_entries ORDER BY id DESC");
>
> $nRows = mysql_num_rows($qResult);
> $rString ="&n=".$nRows;
>
> If I am just naming a variable how is the argument not valid?
What it's saying is that MySQL didn't like something you did, so could
*NOT* give you back your blog_entries.
So the $qResult is *NOT* a set of blog_entries.
It's fasically just got the value FALSE in it -- because that's what
mysql_query() returns when you mess up.
The most likely source of your trouble is that your SQL query is 'wrong'
somehow.
Since it's so simple, we can pretty much say that either glob_entries is
not the right table, or 'id' isn't the right field name.
In general, however, you should do:
$qResult = mysql_query(...) or trigger_error(mysql_error(), E_USER_ERROR);
http://php.net/mysql_error
will tell you EXACTLY what MySQL doesn't like.
PS
It's also possible (though unlikely given the actual error message and
code you shows us) that you never connected to your database.
You should do the same kind of thing with mysql_error where you do your
mysql_connect().
--
Like Music?
http://l-i-e.com/artists.htm
Navigation:
[Reply to this message]
|