You are here: COUNT syntax « PHP SQL « IT news, forums, messages
COUNT syntax

Posted by listerofsmeg01 on 10/08/05 00:24

Newbie here again.

I am trying to find the position of a record using COUNT, but I think I
must be doing something wrong:

$query = "Select COUNT(*) as HPos from Highscores where Score >
$nScore";
$resultid = mysql_query ($query, $chan);
if (!$resultid)
die('Error getting position:' . mysql_error());

$row = mysql_fetch_array($result);
$nPosition = $row['HPos'];
echo "POS=";
echo $nPosition;


I always get a POS of 0 despite there being plenty of rows in the
table. I still get the same even if I take out the "Score > $nScore".

If I run the same query via PHPAdmin it works fine, so I'm obviously
getting some kind of syntax wrong in my PHP script.

Help!

 

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

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