?
Solved

Load Data from file on server to MySQL using PHP

Posted on 2009-04-03
3
Medium Priority
?
185 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

800 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