Re: Load Data Local Infile
| From: | Jayme Jeffman Filho | Date: | Sun, 16 Jul 2000 23:41:53 +0000 |
| Subject: | Re: Load Data Local Infile | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-1164@lists.php.net to get a copy of this message | ||
Sorry but it didn't work out.
I made a web page like you did and used the same way you told me worked out
for you. I don't know if my ISP MySQL configuration allows me to run Load
Data Local Infile, because I've been getting allways the same error "File
'C:\prod.txt' not found - error(2)". You can try at
www.sharpmaster.com.br/manbd/tblupdt.html .
The PHP code I used is shown bellow :
<?PHP
include("shmtlib.php");
if(isset($filename) && isset($tablename)){
echo("<!-- $filename -->");
echo("<!-- $tablename -->");
if(shmtConnect("jjeffman") > 0){
$query = "LOAD DATA LOCAL INFILE '";
$query .= addSlashes($filename) ;// without double slashes the file
becomes "C:prod.txt" instead of "C:\prod.txt"
$query .= "' REPLACE INTO TABLE $tablename" ;// Using quotes raises a
parse error
$query .= " FIELDS TERMINATED BY '0x7c'";//Without quotes raises a SQL
error
$query .= " LINES TERMINATED BY '\\n'";
echo("<!-- $query -->");
$result = mysql_query($query);
}
}
else
echo("Filename ou table not defined !");
?>
<H5 ALIGN="CENTER">SQL Command Result</H5>
<?PHP
if($result == 0)
echo("<B>Error No. " . mysql_errno() . " : " . mysql_error() .
"</B>");
else
echo("<B>Success !</B>");
?>
-----Mensagem original-----
De: Don Smith <don@newsvideo.com>
Para: jjeffman@conex.com.br <jjeffman@conex.com.br>
Data: Domingo, 16 de Julho de 2000 10:59
Assunto: Load Data Local Infile
>Here's the code that has worked well for me:
>
>$sql2 = "LOAD DATA LOCAL INFILE '$userfile' INTO TABLE products
> FIELDS TERMINATED BY 0x7c
> LINES TERMINATED BY '\n'";
<cut>
>
>Hope this helps.
>
>Don Smith
>NewsVideo.com
>