Basic of basic debugging:
Generate your sql outside of the mysql_query() and echo it to screen.
Use mysql_num_rows() to discover how many rows have been returned.
ONLY if you get 1 or more rows would a call to mysql_fetch_array() be valid and you ideally ought therefore to use the number generated by mysql_num_rows() to decide whether to actually use the array.
<?php
$sql = "SELECT * FROM table WHERE cat='$cat'";
echo $sql . " rows returned<br>";
$result = mysql_query("$sql", $db);
$num_results = mysql_num_rows($result);
echo $num_results . " rows returned<br>";
if ($num_results != "0") {
while($row = mysql_fetch_array($result)) {
echo $row['name'];
};
}; // End of if ($num_results != "0")
?>
Initially echoing the sql should confirm that your sql actually has a string or value which which to query the database. If that string/value never makes it to the sql, you'll soon see because it won't be in the echo'd sql.
Next, by checking how many results are returned before trying to loop through non existent results, your script don't break. It is perfectly feasable that the WHERE within your sql does not match any records.
Table and field names are cASe SensiTIve