RE: Load data infile problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:jhaddad@xxxxxxxxxxxxxxxxx] 
Sent: Tuesday, 8 June 2004 2:06 PM
To: Baiocchi, Justin (LI, Armidale)
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  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, <Justin.Baiocchi@xxxxxxxx> 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
jhaddad@xxxxxxxxxxxxxxxxx
http://www.superwebstuff.com

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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux