正如标题所解释的那样,我收到了错误:
Undefined offset: 1,2,3 in <file> on line ...
不偏移0?
$csv_file = $filename;
$csvfile = fopen($csv_file, 'r');
$theData = fgets($csvfile);
$i = 0;
while (!feof($csvfile)) {
$csv_data[] = fgets($csvfile, 1024);
$csv_array = explode(",", $csv_data[$i]);
$insert_csv = array();
$insert_csv['Point_number'] = $csv_array[0];
$insert_csv['Easting'] = $csv_array[1];
$insert_csv['Northing'] = $csv_array[2];
$insert_csv['Reduced_level'] = $csv_array[3];
$query = "INSERT INTO export(point_number,easting,northing,reduced_level)
VALUES('".$insert_csv['Point_number']."','".$insert_csv['Easting']."','".$insert_csv['Northing']."','".$insert_csv['Reduced_level']."')";
$n=mysql_query($query, $connect );
$i++;
}
fclose($csvfile);
答案 0 :(得分:0)
$csv_array[1];
,$csv_array[2];
和$csv_array[3];
不存在于$csv_array
内。如建议的那样,在var_dump($csv_array)
下面$csv_array = explode(",", $csv_data[$i]);
,看看那里有什么!