Fix warnings and mysql_num_rows

This add real php warnings and fixes an error in mysql_num_rows when the sql statement errors out.