Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 31st, 2003, 11:17 PM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to load data into a table?

i am using mysql version 4 and have created a text file `pet.txt' containing one record per line, with values separated by tabs, and given in the order in which the columns were listed in the CREATE TABLE statement. For missing values i represent it with \N (backslash, capital-N). i save the file in my root document for web server which is C:\Inetpub\wwwroot\project.

To load the text file `pet.txt' into the pet table, i use this command:
    LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;

but i get this error.
    ERROR: File 'pet.txt' not found (Errcode: 2)

Is this because i save my pet.txt in the wrong directory? is yes, where should i save it?
Please help!

Reply With Quote
  #2 (permalink)  
Old November 1st, 2003, 04:23 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi hosefo,

There is a lengthy page all about this in the MySQL manual. My suggestion is give it a good study.

Quote from the manual page:
Quote:
quote:
When locating files on the server host, the server uses the following rules:

If an absolute pathname is given, the server uses the pathname as is.
If a relative pathname with one or more leading components is given, the server searches for the file relative to the server's data directory.
If a filename with no leading components is given, the server looks for the file in the database directory of the current database.
So whatever directory that the database itself is located in is where the text file needs to be saved, or you can just plug in the tried and true absolute path.

http://www.mysql.com/doc/en/LOAD_DATA.html

hth,
: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #3 (permalink)  
Old November 2nd, 2003, 11:17 PM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I already put the pet.txt file in the directory that the database itself is located but i still can't load that file. i still get the error below
    ERROR: File 'pet.txt' not found (Errcode: 2)


Reply With Quote
  #4 (permalink)  
Old November 3rd, 2003, 02:31 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I think that this may have something to do with your use of the 'LOCAL' keyword. The manual page stipulates that the LOCAL keyword will load a file from the standpoint of the client-side... MySQL sends a request to the client-side program and requests it to upload that file. So in order to use LOCAL I think that you would need to use an absolute path. If the LOCAL keyword is not specified then MySQL will look for the file from the server-side standpoint, whereas you may access the file from the database directory, a relative path from the root www directory (methinks anyhow, the manual says the server data directory), or an absolute path.

That's my suspicion. The manual page also mentions security settings that need to be in place before accessing the file server-side will be possible.

If you want to stay with the LOCAL keyword, plug in an absolute path. Which would be something like this.

C:\\Inetpub\\wwwroot\\project\\pet.txt

hth
: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic load of hash table jcwest Visual Basic 2005 Basics 0 October 29th, 2007 11:03 PM
Load Report Failed - Invalid Table Number rstaubitz Crystal Reports 0 December 28th, 2005 10:07 AM
page take time to load after adding rows in table avanishp General .NET 5 June 21st, 2005 02:32 PM
trying to load db data into data grid itsajourney Beginning VB 6 2 June 7th, 2005 12:05 PM



All times are GMT -4. The time now is 02:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.