Solved

Load Data from file on server to MySQL using PHP

Posted on 2009-04-03
3
175 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

762 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

20 Experts available now in Live!

Get 1:1 Help Now