此代码正常运行但fclose()
最终未运行。
有人能用我的代码发现问题吗?
<?php
$ImagePath=$newpath;
$csvfile = fopen($ImagePath, 'r');
$i=0;
while (!feof($csvfile)) {
$csv_data[] = fgets($csvfile, 1024);
$csv_array = explode(",", $csv_data[$i]);
$insert_csv = array();
$insert_csv['Company_ID'] = $csv_array[0];
$insert_csv['Close_Value'] = $csv_array[7];
$table_exists_or_not = "SELECT * FROM '".$insert_csv['Company_ID']."'";
$table_exists_or_not_result = mysqli_query($table_exists_or_not);
if(empty($table_exists_or_not_result)){
$sql = "CREATE TABLE `".$insert_csv['Company_ID']."` ( `date` VARCHAR(8) NOT NULL , `value` DECIMAL(11,2) NOT NULL , UNIQUE (`date`) ) ENGINE = InnoDB";
$result = mysql_query($sql);
$qry1="INSERT INTO `".$insert_csv['Company_ID']."` (`date`, `value`) VALUES ('$date', '".$insert_csv['Close_Value']."')";
$add1=mysql_query($qry1);
}else{
$qry1="INSERT INTO `".$insert_csv['Company_ID']."` (`date`, `value`) VALUES ('$date', '".$insert_csv['Close_Value']."') ";
$add1=mysql_query($qry1);
}
$i++;
}
fclose($csvfile);
?>