I have a little problem when trying to count the number of results returned
in a mysql query. I was using mysql_num_rows() to do it with no problems,
but this isn't as quick as using mySQL's COUNT(*), or so I have been told so
I swtiched. Here's a snipit of the code...
$sqlinfo = "SELECT username, COUNT(username) as count FROM usertable WHERE
username='me' GROUP BY username";
$sqlresult = mysql_query($sqlinfo)
or die(mysql_error());
$count = mysql_result($sqlresult,0,"count");
if ($count <= 0) {
....FAILED....
} else {
while ($row = mysql_fetch_array($sqlresult)) {
$username = $row['username'];
}
}
The count value is set correctly but: when the while() loop is
executed...no values are set (there are a lot more, but I shortened it for
spaces sake). So, $username is null. If I remove the $count line, it
works....any suggestions?
Max
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php