Click to See Complete Forum and Search --> : importing file of text in db MySql


Anon
02-22-2001, 04:25 AM
I wanted to ask where it is the error, in importing file of text in db the MySql

Name DB: prova
Table: test -> row (id, colore, sapore)

--------------------Language PHP-----------
<?
$dbaddress="localhost";
$login="";
$password="";
$dbname="prova";

if(!($conn=mysql_connect($dbaddress,$login,$password)))
{echo"Connessione al server non riuscita";}

mysql_select_db($dbname,$conn);

$query=mysql_query("LOAD DATA LOCAL INFILE 'tabella2.txt' INTO TABLE test FIELDS TERMINATED BY ';' ENCLOSED BY '"' (id, colore, sapore)");
if(!($result=mysql_query($query,$conn)))
{echo"<center>Errore nella query di eliminazione</center>";}


// Chiusura connessione
mysql_close($conn);
?>
------------------------------------------

----------------File of text--------------
1;"giallo";"canarino"
2;"rosso";"fragola"
------------------------------------------

Thanks

Anon
02-22-2001, 11:53 AM
Probably right here:

"... ENCLOSED BY '"' ...";

Try:

"... ENCLOSED BY '\"' ...";