Solved

Load Data from file on server to MySQL using PHP

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

705 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