Hallo,
unzwar brauche ich im Moment ein Uploadscript für eine größere Tabelle:
Problem. Es geht nicht. Könnt ihr mir helfen?
Quelltext:
<?php $mysqlhost="localhost";$mysqluser="anonymous"; $mysqlpwd=""; $mysqldb="praktikant"; $connection=mysql\_connect($mysqlhost, $mysqluser, $mysqlpwd) or die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=mysqlConnect")); mysql\_select\_db("praktikant", $connection) or die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=mysqlDBSelect")); if (($\_FILES["file"]["type"] == "text/comma-separated-values") || ($\_FILES["file"]["type"] == "application/vnd.ms-excel") || ($\_FILES["file"]["type"] == "text/x-csv") && ($\_FILES["file"]["size"] \< 200000 \* 8)) { if ($\_FILES["file"]["error"] \> 0) { if (file\_exists($\_FILES["file"]["tmp\_name"])) unlink($\_FILES["file"]["tmp\_name"]); die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=file")); } else { $csvd = fopen($\_FILES["file"]["tmp\_name"], "r"); $query = "TRUNCATE `feige`"; mysql\_query($query) or die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=mysqlEmpty")); while (!feof($csvd)) { $buffer = fgets($csvd, 4096); $splitrow = getCSVValues($buffer, ";"); $query = "INSERT INTO `feige` (`Firstname`, `Lastname` , `Phone` , `Mobile` , `Position` , `Email` ,) VALUES ( NULL , '". $splitrow[1]."', '". $splitrow[2]."', '". $splitrow[3]."', '". $splitrow[4]."', '". $splitrow[5]."');"; mysql\_query($query) or die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=mysqlInsert")); $index = 0; } $fp = fopen("./date.inc", "w"); fwrite($fp, date("d-m-y")); fclose($fp); fclose ($csvd); unlink($\_FILES["file"]["tmp\_name"]); //$sql = "LOAD DATA LOCAL INFILE '" . $\_FILES['file']['tmp\_name'] . "' REPLACE INTO TABLE `adressen` FIELDS TERMINATED BY ';' ENCLOSED BY '\"' "; //mysql\_query($sql) or die(mysql\_error()); } } else { if (file\_exists($\_FILES["file"]["tmp\_name"])) unlink($\_FILES["file"]["tmp\_name"]); die(header("Location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=fileCSV")); } header("location: /typo3conf/ext/hb\_tel/mod1/index.php?&id=0&error=suc6"); if (file\_exists($\_FILES["file"]["tmp\_name"])) unlink($\_FILES["file"]["tmp\_name"]); // CSV Function function getCSVValues($string, $separator=";") { $elements = explode($separator, $string); for ($i = 0; $i 0) { // Put the quoted string's pieces back together again array\_splice($elements, $i, $j-$i+1, implode($separator, array\_slice($elements, $i, $j-$i+1))); break; } } } if ($nquotes \> 0) { // Remove first and last quotes, then merge pairs of quotes $qstr =& $elements[$i]; $qstr = substr\_replace($qstr, '', strpos($qstr, '"'), 1); $qstr = substr\_replace($qstr, '', strrpos($qstr, '"'), 1); $qstr = str\_replace('""', '"', $qstr); } } return $elements; } ?\> mfG Thomas