You are here: Re: [PHP] Php error with MySql « PHP « IT news, forums, messages
Re: [PHP] Php error with MySql

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация