RE: [PHP-DB] Load data infile problem

From: Date: Tue, 08 Jun 2004 04:36:17 +0000
Subject: RE: [PHP-DB] Load data infile problem
Groups: php.db 
Request: Send a blank email to php-db+get-34678@lists.php.net to get a copy of this message
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@superwebstuff.com] Sent: Tuesday, 8 June 2004 2:06 PM To: Baiocchi, Justin (LI, Armidale) Cc: php-db@lists.php.net 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, <Justin.Baiocchi@csiro.au> 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@superwebstuff.com http://www.superwebstuff.com

« previous php.db (#34678) next »