[PHP-DB] load data infile -- problem

2005-08-18 Thread select.now

Helo everyone !
I find this problem and I think I am close to the solution but ...

The question: I need to import a few thousand of record storee in a *.csv 
file on my local harddisk, with my php application, managing my mysql engine.


So, in command line, all works fine, all records are correctly imported.
 command line code -
mysql load data infile 'c:\\datastream\\import\import
-into table iport
- fields terminated by ';'
- ignore 9 lines;
- /command line code 

But in my php app, because I am confuse a bit (use of ['], [] and the 
definition of variables in mysql_query), I don't make this import.


-- php code ---
$a = 'c:\\\datastream\\\import\\\import';
$extra_arg = 'fields terminated by \';\' ignore 9 lines;';
$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.'';
$result = mysql_query ($query) or die_mysql (brExecutia comenzii 
i$query/i a esuat.br);

-- /php code --

I get this output-error:
===
 load data infile 'c:\\datastream\\import\\import' into table import 
fields terminated by ';' ignore 9 lines;

===
and the import doesn't occured.


Where is located my mistake ?

Thanks in advance.

--
cu respect, [EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] load data infile -- problem

2005-08-18 Thread Miles Thompson


I could be 100% wrong on this, but I do not think that a command line 
statement can be executed through mysql_query() - try exec().
If I remember correctly mysql load data infile ... is not executed from 
within mysql, but at the command line.


(Hint: look at the source for phpMyAdmin and copy how it is done.)

Regards - Miles


At 08:30 AM 8/18/2005, select.now wrote:

Helo everyone !
I find this problem and I think I am close to the solution but ...

The question: I need to import a few thousand of record storee in a *.csv 
file on my local harddisk, with my php application, managing my mysql engine.


So, in command line, all works fine, all records are correctly imported.
 command line code -
mysql load data infile 'c:\\datastream\\import\import
-into table iport
- fields terminated by ';'
- ignore 9 lines;
- /command line code 

But in my php app, because I am confuse a bit (use of ['], [] and the 
definition of variables in mysql_query), I don't make this import.


-- php code ---
$a = 'c:\\\datastream\\\import\\\import';
$extra_arg = 'fields terminated by \';\' ignore 9 lines;';
$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.'';
$result = mysql_query ($query) or die_mysql (brExecutia comenzii 
i$query/i a esuat.br);

-- /php code --

I get this output-error:
===
 load data infile 'c:\\datastream\\import\\import' into table import 
fields terminated by ';' ignore 9 lines;

===
and the import doesn't occured.


Where is located my mistake ?

Thanks in advance.

--
cu respect, [EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] load data infile -- problem

2005-08-18 Thread dpgirago
You can definitely do a load file from within the mysql client, so I'd 
guess you can do it through mysql_query, too. I'm wondering about the 
semi-colon within the query. Maybe it needs to be escaped, too.

David

 I could be 100% wrong on this, but I do not think that a command line 
 statement can be executed through mysql_query() - try exec().
 If I remember correctly mysql load data infile ... is not executed from 
 within mysql, but at the command line.

 (Hint: look at the source for phpMyAdmin and copy how it is done.)

 Regards - Miles


At 08:30 AM 8/18/2005, select.now wrote:
Helo everyone !
I find this problem and I think I am close to the solution but ...

The question: I need to import a few thousand of record storee in a 
*.csv 
file on my local harddisk, with my php application, managing my mysql 
engine.

So, in command line, all works fine, all records are correctly imported.
 command line code -
 mysql load data infile 'c:\\datastream\\import\import
-into table iport
- fields terminated by ';'
- ignore 9 lines;
- /command line code 

But in my php app, because I am confuse a bit (use of ['], [] and the 
definition of variables in mysql_query), I don't make this import.

-- php code ---
$a = 'c:\\\datastream\\\import\\\import';
$extra_arg = 'fields terminated by \';\' ignore 9 lines;';
$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.'';
$result = mysql_query ($query) or die_mysql (brExecutia comenzii 
i$query/i a esuat.br);
-- /php code --

I get this output-error:
===
  load data infile 'c:\\datastream\\import\\import' into table import 
 fields terminated by ';' ignore 9 lines;
===
and the import doesn't occured.


Where is located my mistake ?

Thanks in advance.

--
cu respect, [EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] load data infile -- problem

2005-08-18 Thread Bastien Koert
is the file sitting on the same server as the db? Are the webserver and db 
on the same machine? If they are not, and the file uploaded to the 
webserver, the db sesrver machine won't have access to the file unless you 
ftp it over...


You may want/need to investigate a more php based approach where you open 
the file and read it in, parsing thru it to access the data elements and 
running sql statements thru a loop


Bastien



From: [EMAIL PROTECTED]
To: Miles Thompson [EMAIL PROTECTED]
CC: php-db-list php-db@lists.php.net
Subject: Re: [PHP-DB] load data infile -- problem
Date: Thu, 18 Aug 2005 09:25:22 -0500

You can definitely do a load file from within the mysql client, so I'd
guess you can do it through mysql_query, too. I'm wondering about the
semi-colon within the query. Maybe it needs to be escaped, too.

David

 I could be 100% wrong on this, but I do not think that a command line
 statement can be executed through mysql_query() - try exec().
 If I remember correctly mysql load data infile ... is not executed from
 within mysql, but at the command line.

 (Hint: look at the source for phpMyAdmin and copy how it is done.)

 Regards - Miles


At 08:30 AM 8/18/2005, select.now wrote:
Helo everyone !
I find this problem and I think I am close to the solution but ...

The question: I need to import a few thousand of record storee in a
*.csv
file on my local harddisk, with my php application, managing my mysql
engine.

So, in command line, all works fine, all records are correctly imported.
 command line code -
 mysql load data infile 'c:\\datastream\\import\import
-into table iport
- fields terminated by ';'
- ignore 9 lines;
- /command line code 

But in my php app, because I am confuse a bit (use of ['], [] and the
definition of variables in mysql_query), I don't make this import.

-- php code ---
$a = 'c:\\\datastream\\\import\\\import';
$extra_arg = 'fields terminated by \';\' ignore 9 lines;';
$query = 'load data infile \''.$a.'\' into table import '.$extra_arg.'';
$result = mysql_query ($query) or die_mysql (brExecutia comenzii
i$query/i a esuat.br);
-- /php code --

I get this output-error:
===
  load data infile 'c:\\datastream\\import\\import' into table import
 fields terminated by ';' ignore 9 lines;
===
and the import doesn't occured.


Where is located my mistake ?

Thanks in advance.

--
cu respect, [EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Load data infile problem

2004-06-07 Thread Justin.Baiocchi
Hello, 
 
I have a page with a button that when clicked loads a pre-determined
text file into my database. The code is posted below.
However, when clicked the button does nothing, just opens up the same
page again. The data does not get loaded into the database. any ideas?
 
Thanks
Justin
 
The page is viewall.php which has the button on it. So I want it (when
clicked) to update the database and return to the page.
 
 
 
td width=100% align=center
  
?php
if ($submit) {
$dbH = mysql_connect('localhost', 'root', 'password') or die('Could
not connect to MySQL server.br' . mysql_error());
 
mysql_select_db(options);
 
$sql = 'LOAD DATA INFILE \'C:abc.txt\' REPLACE INTO TABLE `abc`'
. 'FIELDS TERMINATED BY \'\\t\''
. 'ENCLOSED BY \'\''
. 'ESCAPED BY \'\''
. 'LINES TERMINATED BY \'\\r\\n\'';
}
? 
 
?php
$d = form method=post action='viewall.php'. input type=submit
name=submit value='Submit'/form;
echo $d; ?
/td


RE: [PHP-DB] Load data infile problem

2004-06-07 Thread Justin.Baiocchi
Actually, I have just figured it out. It had to do with the 'slashes'
around the query. The original $sql code was created using phpmyadmin,
but I messed around with it until it worked, now using the following
query:

mysql_query(LOAD DATA INFILE 'C:abc.txt' INTO TABLE abc FIELDS
TERMINATED BY '\\t' ESCAPED BY '\\\' LINES TERMINATED BY '\\r\\n');

So it was the query formatting which was the problem.

Thanks
Justin


-Original Message-
From: Jonathan Haddad [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 8 June 2004 2:06 PM
To: Baiocchi, Justin (LI, Armidale)
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Load data infile problem


does your server have the post variables set as globals?  you might 
have to use $_POST['submit'] instead.

On Jun 7, 2004, at 9:17 PM, [EMAIL PROTECTED] wrote:

 Hello,

 I have a page with a button that when clicked loads a pre-determined
 text file into my database. The code is posted below.
 However, when clicked the button does nothing, just opens up the same
 page again. The data does not get loaded into the database. any ideas?

 Thanks
 Justin

 The page is viewall.php which has the button on it. So I want it (when
 clicked) to update the database and return to the page.



 td width=100% align=center

 ?php
 if ($submit) {
 $dbH = mysql_connect('localhost', 'root', 'password') or
die('Could
 not connect to MySQL server.br' . mysql_error());

 mysql_select_db(options);

 $sql = 'LOAD DATA INFILE \'C:abc.txt\' REPLACE INTO TABLE 
 `abc`'
 . 'FIELDS TERMINATED BY \'\\t\''
 . 'ENCLOSED BY \'\''
 . 'ESCAPED BY \'\''
 . 'LINES TERMINATED BY \'\\r\\n\'';
 }
 ?

 ?php
 $d = form method=post action='viewall.php'. input type=submit
 name=submit value='Submit'/form;
 echo $d; ?
 /td

--
Jonathan Haddad
[EMAIL PROTECTED]
http://www.superwebstuff.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] load data infile problem

2002-01-19 Thread rop30999

I have a called file cats.txt which count data that were solitary of a DB
Access.
I need to export these data for a table 'cats' inside of a DB done in MySql.

In MySql I can execute this procedure in the following way:

Load data local infile gatos.txt
into table gatos
fields
terminated by ','
enclosed by ''
(Id, Nome, Raça);

I need to know how I can accomplish this same operation but using PHP

Thank you

Paulo



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] load data infile problem

2002-01-19 Thread Miles Thompson

You running Windows or *nix?  File permissions will play a part in this, 
but use PHP's exec() function to execute MySQL's load data infile. The 
manual has a number of well annotated examples. The big problem may be that 
you'll be executing the command as whatever user the web server is running as.

But before you start reinventing the wheel,  search for MySQL import csv 
PHP, or something similar, and check out the script sites referred to in 
the links part of the manual. This isn't a new problem and has been 
addressed before.

HTH - Miles Thompson


At 09:13 PM 1/19/2002 +, rop30999 wrote:
I have a called file cats.txt which count data that were solitary of a DB
Access.
I need to export these data for a table 'cats' inside of a DB done in MySql.

In MySql I can execute this procedure in the following way:

Load data local infile gatos.txt
into table gatos
fields
terminated by ','
enclosed by ''
(Id, Nome, Raça);

I need to know how I can accomplish this same operation but using PHP

Thank you

Paulo



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]