'Resource id #2' is not an error. It is the resource id of your result. If you want to substract information from your result, you need to use other functions, for example:
<?
$connect = mysql_connect("localhost","root","") or die("connection to database failed!");
mysql_select_db("mw") or die( "cannot select database" );
$result=mysql_query("select count(StaffID) AS howmany from LeaveApplication1 where StaffID = 'fui'") ;
if( !$result) {
// ALERT!!! NO RESULT, THE HAS QUERY FAILED
echo mysql_error($connect);
}
echo mysql_result( $result, 0 , 'howmany');
// mysql_result( *var_containing result*, *row number*, *field name* )
mysql_close();
?>
The $result itself contains a table.