To get your code working will depend on what you are actually wanting to achieve.
You may want the row count AND each row returned for processing or just the total.
To get the count of matching rows AND the rows you could use a snippet similar to this...
$query = "SELECT * FROM my_table";
$result = do_query ($query, $db_link);
$u_rows = mysql_num_rows($result);
If however you just want the count than I would probably use something along the lines off....
$query = "SELECT count(*) as rtotal FROM my_table";
$result = do_query ($query, $db_link);
$row = mysql_fetch_array($result);
$rtotal = $row['rtotal'];
Hope that this helps.
and since I managed to lose it from the original attempt at posting...
function do_query ($query, $db_link) {
$result = @mysql_query($query, $db_link);
if (!$result) {
error("$query");
fatal_error("A database query error has occurred!");
} else {
return($result);
}
}
The code example above requires the db_link variable to be returned from the original database connection.