Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/06/2013, 02:36
Avatar de hellsingstq
hellsingstq
 
Fecha de Ingreso: junio-2013
Ubicación: Madrid
Mensajes: 12
Antigüedad: 10 años, 10 meses
Puntos: 0
Pregunta Importar cualquier archivo .csv

Caballeros, tengo el siguiente script:

<?php
$server = 'localhost';
$user = 'alvaro';
$passwort = 'alvaro';
$database = 'certifications';
$file = 'D:/CISCO OSZIMT/MySQL/import.csv';

$verbindung = mysql_connect($server, $user, $passwort) or die ("Keine Verbindung m&ouml;glich");

if($verbindung){
$db= mysql_select_db($database) or die ("Die Datenbank existiert nicht");
$sql = "LOAD DATA LOCAL INFILE '$file'
INTO TABLE students
FIELDS TERMINATED BY ';'
ENCLOSED BY ''
LINES TERMINATED BY '\n' ";

echo mysql_error();
if($sql){
$ergebnis = mysql_query($sql);
if($ergebnis){
echo "Datas written in table $ergebnis . <br>";

}
else
{
echo "Failed to write Datas into table";
}

echo "<table border='1'>";
echo "<tr>
<th>Number</th>
<th>Name</th>
<th>Surname</th>
<th>Teacher</th>
<th>Classname</th> </tr>";
$select_data = "Select * from `students`";
$select_data = mysql_query ("Select * from `students`");
while($row = mysql_fetch_row($select_data))
{
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row[0];
echo "</td><td>";
echo $row[1];
echo "</td><td>";
echo $row[2];
echo "</td><td>";
echo $row[3];
echo "</td><td>";
echo $row[4];
echo "</td></tr>";
}

echo "</table>";
}

}
mysql_close($verbindung);
?>

Todo funciona excepto una cosa, quiero poder coger cualquier archivo, independientemente de la ruta. Como puedo hacer eso??
Gracias de antemano x la ayuda!