Solved

Load Data from file on server to MySQL using PHP

Posted on 2009-04-03
3
177 Views
Last Modified: 2013-12-12
Okay so I'm trying to do simple things and can't seem to get anything working.  Can someone tell me what is wrong?
Structure is such:

/
/feed
/feed/1132
file called load.php is located in /feed/1132 along with the data text files
below is the code.  Why isn't it working?
<?php

$dbc=mysql_connect ("localhost", "shopn8_imptinv",

"greenimpt") or die('Cannot connect to the database because: ' . mysql_error());

mysql_select_db ("shopn8_imptinv");

mysql_query("LOAD DATA INFILE '20090401_1132.txt' INTO TABLE invdat FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' IGNORE 1 LINES");

?>

Open in new window

0
Comment
Question by:PageMasterRWS
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
Gawai earned 500 total points
ID: 24061439
try
mysql_query("LOAD DATA INFILE '20090401_1132.txt' INTO TABLE invdat FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n' IGNORE 1 LINES", $dbc);

or
save that query in .sql and

mysql_query("\. pathto\myfile.sql", $dbc);
0
 

Author Closing Comment

by:PageMasterRWS
ID: 31566305
Thanks so much...forgot that part I suppose.  Now I have a rights issue but I'll work that out myself.  Thanks so much again for your help!
0
 
LVL 20

Expert Comment

by:Gawai
ID: 24062030
u r most welcome :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now