If you use COUNT(), it'll only return 1 row. But if you use simply , you can use mysql_num_rows($res) and get the same result. Just an extra step if you really need to use COUNT(*)
<?php
mysql_connect($host,$login,$pass);
mysql_select_db($db);
$sql = "SELECT COUNT(*) FROM $table";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$var = $row[0];
echo $var;
?>