Use [man]mysql_real_escape_string[/man] to escape string input with the MySQL extension, e.g.,
while (($data = fgetcsv($handle, 100000, "|")) !== FALSE) {
$import = sprintf("INSERT INTO commercial
(Transaction_Type, MLSNumber, ListOfficeId, ListOfficeAddress1)
VALUES('%s', '%s', '%s', '%s')",
mysql_real_escape_string($data[0]),
mysql_real_escape_string($data[1]),
mysql_real_escape_string($data[2]),
mysql_real_escape_string($data[3]));
mysql_query($import) or die(mysql_error());
}
If feasible, I suggest switching to either the MySQLi extension or PDO extension, and perhaps using prepared statements with these extensions instead.