Visto che non riuscivo ad arginare l'altro problema ho risolto in un'altra maniera.
Importo tramite la classe excelreader ed uno script i dati direttamente da excel al mio database.
Funzionava tutto bene, ma per l'ultima tabella ho dei problemi e non riesco a capire perche :
Codice PHP:
<?php
// Test CVS
require_once 'reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read('telefono.xls'); // e' il nome del mio file excel
$db_host = "localhost";
$db_user = "xxx";
$db_pass = "";
$db_name = "xxx";
$db_conn = mysql_connect($db_host, $db_user, $db_pass, $db_name) or die ("Errore connessione:" . mysql_error());
mysql_select_db($db_name, $db_conn);
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++){
$_POST['ID']= "".$data->sheets[0]['cells'][$i][1]."";
$_POST['cognome']= "".$data->sheets[0]['cells'][$i][2]."";
$_POST['nome']= "".$data->sheets[0]['cells'][$i][3]."";
$_POST['a']= "".$data->sheets[0]['cells'][$i][4]."";
$_POST['a1']= "".$data->sheets[0]['cells'][$i][5]."";
$_POST['a2']= "".$data->sheets[0]['cells'][$i][6]."";
$_POST['a3']= "".$data->sheets[0]['cells'][$i][7]."";
$_POST['a4']= "".$data->sheets[0]['cells'][$i][8]."";
$_POST['a5']= "".$data->sheets[0]['cells'][$i][9]."";
$_POST['a6']= "".$data->sheets[0]['cells'][$i][10]."";
$_POST['a7']= "".$data->sheets[0]['cells'][$i][11]."";
$_POST['a8']= "".$data->sheets[0]['cells'][$i][12]."";
$_POST['a9']= "".$data->sheets[0]['cells'][$i][13]."";
$_POST['a10']= "".$data->sheets[0]['cells'][$i][14]."";
$_POST['a11']= "".$data->sheets[0]['cells'][$i][15]."";
$_POST['a12']= "".$data->sheets[0]['cells'][$i][16]."";
$_POST['a13']= "".$data->sheets[0]['cells'][$i][17]."";
$_POST['a14']= "".$data->sheets[0]['cells'][$i][18]."";
$_POST['a15']= "".$data->sheets[0]['cells'][$i][19]."";
$_POST['a16']= "".$data->sheets[0]['cells'][$i][20]."";
$_POST['a17']= "".$data->sheets[0]['cells'][$i][21]."";
//inserisco nella tabella i dati estratti
$query="INSERT INTO utenti (id, appellativo, cognome, nome, qualifica, ente, presso, universita, via, civico, cap, citta, provincia, nazione, prefax, fax, rapporti, riferimento, professione, mail, altramail)
VALUES ('{$_POST['ID']}','{$_POST['cognome']}','{$_POST['nome']}','{$_POST['a']}','{$_POST['a1']}','{$_POST['a2']}','{$_POST['a3']}','{$_POST['a4']}','{$_POST['a5']}','{$_POST['a6']}','{$_POST['a7']}','{$_POST['a8']}','{$_POST['a9']}''{$_POST['a10']}''{$_POST['a11']}''{$_POST['a12']}''{$_POST['a13']}''{$_POST['a14']}''{$_POST['a15']}''{$_POST['a16']}''{$_POST['a17']}')";
$dati=mysql_query($query) or die(mysql_error());
if($dati)echo"successo";
else echo"fallimento";
}
?>
Notice: Undefined offset: 2 in C:\wamp\www\phpExcelReader\example.php on line 18
Notice: Undefined offset: 5 in C:\wamp\www\phpExcelReader\example.php on line 21
Notice: Undefined offset: 6 in C:\wamp\www\phpExcelReader\example.php on line 22
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\phpExcelReader\example.php on line 19
Di nuovo edit : penso di aver risolto da solo, al posto di ( ad esempio )
Codice PHP:
$_POST['a12']= "".$data->sheets[0]['cells'][$i][16]."";
ho messo questo
Codice PHP:
$_POST['a12']= isset($data->sheets[0]['cells'][$i][16]) ? $data->sheets[0]['cells'][$i][16] : '';
E' stranamente sparito pure il fatal error ... speriamo che i dati siano stati importati correttamente