0

我有以下文件:

<?php
require_once "conectar_a_base_de_dados.php";
$file = "todos_cp.csv";

if( file_exists($file) )
{
$fh = fopen($file, "r");

while ($line = fgetcsv($fh, 1000, ";"))
{
$id_d = $line[0];
$id_c = $line[1];
$id_f = $line[2];
$freg = $line[3];

$sql = mysql_query("INSERT INTO freguesias (codigo_distrito, codigo_concelho, codigo_freguesia, freguesias)
VALUES('$id_d','$id_c','$id_f','$freg')");
}

fclose($fh);
}
?>

这旨在将数据发送到数据库,但我在 $freg 列上只得到零,我不知道为什么!如果这很重要,我正在使用 wamp 服务器

这是 csv 文件的一小部分:

01;01;249;Alcafaz;;;;;;;;;;;3750;011;AGADÃO
01;01;250;Caselho;;;;;;;;;;;3750;012;AGADÃO
01;01;251;Corga da Serra;;;;;;;;;;;3750;013;AGADÃO
01;01;252;Foz;;;;;;;;;;;3750;014;AGADÃO
01;01;253;Guistola;;;;;;;;;;;3750;015;AGADÃO
4

0 回答 0