Zoals anderen al hebben gezegd, moet je echt PDO gebruiken. Maar om uw vraag te beantwoorden, mysql_num_rows is uw oplossing.
$query = mysql_query("SELECT * FROM products WHERE code='$line_of_data[0]' AND alert_quantity = '$line_of_data[1]'") or die(mysql_error());
if (mysql_num_rows($query))
// Data is already in database
else
// Data not in database