Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2003, 11:17 PM
Authorized User
 
Join Date: Oct 2003
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!

 
Old November 1st, 2003, 04:23 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
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
:::::::::::::::::::::::::::::::::
 
Old November 2nd, 2003, 11:17 PM
Authorized User
 
Join Date: Oct 2003
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)


 
Old November 3rd, 2003, 02:31 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
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
:::::::::::::::::::::::::::::::::





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.