Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Load Data from file on server to MySQL using PHP

Posted on 2009-04-03
3
Medium Priority
?
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
Gawai earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 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