You are here: Re: displaying the result of a COUNT query in MySQL « PHP Programming Language « IT news, forums, messages
Re: displaying the result of a COUNT query in MySQL

Posted by Andy Hassall on 12/19/05 22:47

On 19 Dec 2005 12:24:35 -0800, briansmccabe@gmail.com wrote:

Kimmo originally wrote:

>>$result = mysql_query('SELECT COUNT(*) AS foo FROM table') or
>>die(mysql_error());

But you've used:

>$query6 = "SELECT COUNT (movie_id) as quant FROM movies WHERE divx = 1
>AND format = 'reg'" or die(mysql_error());

You are missing the call to mysql_query().

>$result6 = mysql_fetch_array($query6);

... so $query6 just contains the SQL string, and not a MySQL result set
resource identifier. You're not actually executing the SQL anywhere, or if you
are in the rest of the code, you haven't done the error checking there.

>later on the page:
>
>echo $result6[quant]

This should be: $result6['quant'].

See:

http://www.php.net/manual/en/language.types.array.php#language.types.array.donts

p.s. You've got the posting style nearly right - however you should put your
new message _under_ the old one, not above, so the whole message makes sense
read on its own. You have "top posted".

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

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

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