When I execute this SQL statement in my PHP code, I get an error
"File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt");
$SQL = "Load Data InFile \"" . $File . "\" into table addresses";
$result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file.
How do I generate a relative address for this file so that it can be found?
I'm running on XP Prof..
Thanks...
Bruce 14 9649
Bruce A. Julseth wrote: When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file.
How do I generate a relative address for this file so that it can be found? I'm running on XP Prof..
I suspect MySQL requires a full pathname to the file, because you're running
a SQL command. Although the file is relative to the PHP script MySQL has no
conception of that relative path. Try it with a full pathname and you
should be fine.
If it was a Unix/Linux box you'd need to make sure the MySQL server has
permissions to read from that directory and file, but you probably won't
have this problem on Windows.
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Thanks for the response. I have a problem using absolute path names. I am
developing on a local machine with Apache. When completed, I will upload to
an ISP and I have no idea what the absolute path to my file will be. Any
suggestions here??
Or, does someone else have an idea on how I can use an absolute path.
Thanks...
Bruce
"Chris Hope" <bl*******@electrictoolbox.com> wrote in message
news:10***************@216.128.74.129... Bruce A. Julseth wrote:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file.
How do I generate a relative address for this file so that it can be found? I'm running on XP Prof.. I suspect MySQL requires a full pathname to the file, because you're
running a SQL command. Although the file is relative to the PHP script MySQL has
no conception of that relative path. Try it with a full pathname and you should be fine.
If it was a Unix/Linux box you'd need to make sure the MySQL server has permissions to read from that directory and file, but you probably won't have this problem on Windows.
-- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
In message <40********@news1.prserv.net>, Bruce A. Julseth
<br*****@attglobal.net> writes Thanks for the response. I have a problem using absolute path names. I am developing on a local machine with Apache. When completed, I will upload to an ISP and I have no idea what the absolute path to my file will be. Any suggestions here??
Or, does someone else have an idea on how I can use an absolute path.
I think you need to look at some of the server variables which help with
paths. Whilst you don't know what the absolute path will be, surely you
will know the relative path? Thanks...
Bruce
"Chris Hope" <bl*******@electrictoolbox.com> wrote in message news:10***************@216.128.74.129... Bruce A. Julseth wrote:
> When I execute this SQL statement in my PHP code, I get an error > "File '.\Address.txt' not found (Errcode: 2)" > > $File = addslashes(".\Address.txt"); > $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; > $result = mysql_query($SQL) or die(mysql_error()); > > The file is located in the same directory as my .PHP file. > > How do I generate a relative address for this file so that it can be > found? I'm running on XP Prof..
I suspect MySQL requires a full pathname to the file, because you're running a SQL command. Although the file is relative to the PHP script MySQL has no conception of that relative path. Try it with a full pathname and you should be fine.
If it was a Unix/Linux box you'd need to make sure the MySQL server has permissions to read from that directory and file, but you probably won't have this problem on Windows.
-- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
--
Five Cats
Email to: cats_spam at uk2 dot net
You suggested "Server Variables." I'm new to this game. Can you give me a
few suggestions?
Thanks...
Bruce
"Five Cats" <ca*******@[127.0.0.1]> wrote in message
news:oX**************@[127.0.0.1]... In message <40********@news1.prserv.net>, Bruce A. Julseth <br*****@attglobal.net> writesThanks for the response. I have a problem using absolute path names. I am developing on a local machine with Apache. When completed, I will upload
toan ISP and I have no idea what the absolute path to my file will be. Any suggestions here??
Or, does someone else have an idea on how I can use an absolute path.
I think you need to look at some of the server variables which help with paths. Whilst you don't know what the absolute path will be, surely you will know the relative path?
Thanks...
Bruce
"Chris Hope" <bl*******@electrictoolbox.com> wrote in message news:10***************@216.128.74.129... Bruce A. Julseth wrote:
> When I execute this SQL statement in my PHP code, I get an error > "File '.\Address.txt' not found (Errcode: 2)" > > $File = addslashes(".\Address.txt"); > $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; > $result = mysql_query($SQL) or die(mysql_error()); > > The file is located in the same directory as my .PHP file. > > How do I generate a relative address for this file so that it can be > found? I'm running on XP Prof..
I suspect MySQL requires a full pathname to the file, because you're running a SQL command. Although the file is relative to the PHP script MySQL
hasno conception of that relative path. Try it with a full pathname and you should be fine.
If it was a Unix/Linux box you'd need to make sure the MySQL server has permissions to read from that directory and file, but you probably
won't have this problem on Windows.
-- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
-- Five Cats Email to: cats_spam at uk2 dot net
On Mon, 28 Jun 2004 12:27:30 -0400, "Bruce A. Julseth"
<br*****@attglobal.net> wrote: You suggested "Server Variables." I'm new to this game. Can you give me a few suggestions?
PLEASE stop top posting.
Server Variables:
With bourne: (/bin/sh) and Bash (/usr/bin/bash>
$ VARIABLENAME="variable contents"
$ export VARIABLE NAME
With K shell (/usr/bin/ksh)
export VARIABLENAME="viarable contents"
With CSH (/bin/csh>
setenv VARIABLENAME "variable contents"
type: "set" or "printenv" to see what your settings are now.
Oh, and did I mention you should stop top posting? :)
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://www.databasix.com
================================================== =========================
In message <40********@news1.prserv.net>, Bruce A. Julseth
<br*****@attglobal.net> writes You suggested "Server Variables." I'm new to this game. Can you give me a few suggestions?
http://www.php.net/manual/en/languag...predefined.php
Also create the following script and look at it's output, on both
machines:
<?php
phpinfo();
?>
and see http://uk2.php.net/manual/en/function.phpinfo.php Thanks...
Bruce
"Five Cats" <ca*******@[127.0.0.1]> wrote in message news:oX**************@[127.0.0.1]... In message <40********@news1.prserv.net>, Bruce A. Julseth <br*****@attglobal.net> writes >Thanks for the response. I have a problem using absolute path names. I am >developing on a local machine with Apache. When completed, I will uploadto >an ISP and I have no idea what the absolute path to my file will be. Any >suggestions here?? > >Or, does someone else have an idea on how I can use an absolute path.
I think you need to look at some of the server variables which help with paths. Whilst you don't know what the absolute path will be, surely you will know the relative path?
> >Thanks... > >Bruce > >"Chris Hope" <bl*******@electrictoolbox.com> wrote in message >news:10***************@216.128.74.129... >> Bruce A. Julseth wrote: >> >> > When I execute this SQL statement in my PHP code, I get an error >> > "File '.\Address.txt' not found (Errcode: 2)" >> > >> > $File = addslashes(".\Address.txt"); >> > $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; >> > $result = mysql_query($SQL) or die(mysql_error()); >> > >> > The file is located in the same directory as my .PHP file. >> > >> > How do I generate a relative address for this file so that it can be >> > found? I'm running on XP Prof.. >> >> I suspect MySQL requires a full pathname to the file, because you're >running >> a SQL command. Although the file is relative to the PHP script MySQLhas >no >> conception of that relative path. Try it with a full pathname and you >> should be fine. >> >> If it was a Unix/Linux box you'd need to make sure the MySQL server has >> permissions to read from that directory and file, but you probablywon't >> have this problem on Windows. >> >> -- >> Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ > >
-- Five Cats Email to: cats_spam at uk2 dot net
--
Five Cats
Email to: cats_spam at uk2 dot net
On Sun, 27 Jun 2004 23:28:57 -0400, "Bruce A. Julseth" <br*****@attglobal.net>
wrote: When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file.
Then then command you want would probably be LOAD DATA LOCAL INFILE - note the
LOCAL. Without it, I believe the path is relative to the database data
directory. Or you need an absolute path and stick with LOAD DATA INFILE,
assuming that the MySQL database is running on the same machine as the
webserver.
You can get the current directory with getcwd. http://uk2.php.net/manual/en/function.getcwd.php
Or if you're not necessarily in that directory (perhaps in an include file?)
then dirname(__FILE__). http://uk2.php.net/manual/en/function.dirname.php
I also remember there are security restrictions on usage of LOAD DATA LOCAL
INFILE that depend on MySQL version and compile-time options (possibly
changeable in my.cnf?). See the manual for more information. http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html http://www.mysql.com/news-and-events...000000012.html
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Okay, I'll be happy to stop top posting if I only knew what it is? What is
"top Posting?"
Bruce
"Gary L. Burnore" <gb******@databasix.com> wrote in message
news:cb**********@blackhelicopter.databasix.com... On Mon, 28 Jun 2004 12:27:30 -0400, "Bruce A. Julseth" <br*****@attglobal.net> wrote:
You suggested "Server Variables." I'm new to this game. Can you give me a few suggestions? PLEASE stop top posting.
Server Variables:
With bourne: (/bin/sh) and Bash (/usr/bin/bash>
$ VARIABLENAME="variable contents" $ export VARIABLE NAME
With K shell (/usr/bin/ksh)
export VARIABLENAME="viarable contents"
With CSH (/bin/csh>
setenv VARIABLENAME "variable contents"
type: "set" or "printenv" to see what your settings are now.
Oh, and did I mention you should stop top posting? :)
-- gburnore@databasix dot com --------------------------------------------------------------------------
- How you look depends on where you go. --------------------------------------------------------------------------
- Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³ | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³ DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³ | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³ Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== ========================= Want one? GET one! http://www.databasix.com
================================================== =========================
Bruce A. Julseth wrote: Okay, I'll be happy to stop top posting if I only knew what it is? What is "top Posting?"
Bruce
<snip>
just that. you are responding at the TOP of the orignal message when
netiquette dictates it should FOLLOW (be at the bottom) of the original
message... and if the original message is too long, it can be
appropriate to "snip" the irrelevant parts in your reply.
....like this response.
Michael Austin.
"Michael Austin" <ma*****@firstdbasource.com> wrote in message
news:Xg*****************@newssvr24.news.prodigy.co m... Bruce A. Julseth wrote: Okay, I'll be happy to stop top posting if I only knew what it is? What
is "top Posting?"
Bruce <snip>
just that. you are responding at the TOP of the orignal message when netiquette dictates it should FOLLOW (be at the bottom) of the original message... and if the original message is too long, it can be appropriate to "snip" the irrelevant parts in your reply.
...like this response.
Michael Austin.
Okay... I'll try to remember this in the future. I've only been using
newgroups for about 20 years and this is the first time anyone has told me
that I was wrong...
Bruce
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:qq********************************@4ax.com... On Sun, 27 Jun 2004 23:28:57 -0400, "Bruce A. Julseth"
<br*****@attglobal.net> wrote:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file. Then then command you want would probably be LOAD DATA LOCAL INFILE -
note the LOCAL. Without it, I believe the path is relative to the database data directory. Or you need an absolute path and stick with LOAD DATA INFILE, assuming that the MySQL database is running on the same machine as the webserver.
I'll give this a try. I like it and hope it works. You can get the current directory with getcwd.
I used this and it solved the problem. http://uk2.php.net/manual/en/function.getcwd.php
Or if you're not necessarily in that directory (perhaps in an include
file?) then dirname(__FILE__).
http://uk2.php.net/manual/en/function.dirname.php
I also remember there are security restrictions on usage of LOAD DATA
LOCAL INFILE that depend on MySQL version and compile-time options (possibly changeable in my.cnf?). See the manual for more information.
http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html http://www.mysql.com/news-and-events...000000012.html
I'll give these a try. Thanks. -- Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Bruce A. Julseth wrote: "Michael Austin" <ma*****@firstdbasource.com> wrote in message news:Xg*****************@newssvr24.news.prodigy.co m...
Bruce A. Julseth wrote:
Okay, I'll be happy to stop top posting if I only knew what it is? What is "top Posting?"
Bruce
<snip>
just that. you are responding at the TOP of the orignal message when netiquette dictates it should FOLLOW (be at the bottom) of the original message... and if the original message is too long, it can be appropriate to "snip" the irrelevant parts in your reply.
...like this response.
Michael Austin.
Okay... I'll try to remember this in the future. I've only been using newgroups for about 20 years and this is the first time anyone has told me that I was wrong...
.... me too, and I have always been aware of it.. :) Bruce
Michael Austin.
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:qq********************************@4ax.com... On Sun, 27 Jun 2004 23:28:57 -0400, "Bruce A. Julseth"
<br*****@attglobal.net> wrote:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)"
$File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error());
The file is located in the same directory as my .PHP file. Then then command you want would probably be LOAD DATA LOCAL INFILE -
note the LOCAL. Without it, I believe the path is relative to the database data directory. Or you need an absolute path and stick with LOAD DATA INFILE, assuming that the MySQL database is running on the same machine as the webserver.
I get an error message that this command (LOAD DATA INFILE....) is not
allowed with this version of MySQL. I'm using version 4.0.14-max-debug. You can get the current directory with getcwd.
http://uk2.php.net/manual/en/function.getcwd.php
Or if you're not necessarily in that directory (perhaps in an include
file?) then dirname(__FILE__).
http://uk2.php.net/manual/en/function.dirname.php
I also remember there are security restrictions on usage of LOAD DATA
LOCAL INFILE that depend on MySQL version and compile-time options (possibly changeable in my.cnf?). See the manual for more information.
http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html http://www.mysql.com/news-and-events...000000012.html
-- Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: D. Alvarado |
last post by:
Hello,
I have discovered the beauties of the 'LOAD DATA INFILE' mysql
command. However, I was wondering if someone could help me manipulate
my command to accommodate for the 3 potential types of...
|
by: Phil Powell |
last post by:
I've read some online resources that utilize various MySQL
command-line actions to migrate data from Access to MySQL.
The situation is this: a group of co-workers of mine will be using an
Access...
|
by: Sandra |
last post by:
Hi, I have this problem:
I wish to put a text file into a mysql table.
The text file entries are delimitated by tabs.
Example:
123 456 7 89
(That is, '123' is a data, '456' is a data but...
|
by: Piotr |
last post by:
Hi
I have many files in Excel and I need to transfer them into MySQL, is
tehere any free and easy solution ?
|
by: jrs_14618 |
last post by:
Hello All,
This post is essentially a reply a previous post/thread
here on this mailing.database.myodbc group titled:
MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode
I was...
|
by: greywire |
last post by:
So I need to load lots of data into my database.
So I discover LOAD DATA INFILE.
Great! This little gem loads my CSV in blazing times (compared to
parsing the file and doing INSERT for each...
|
by: Jack |
last post by:
Hi there MYSQL is loading a non printable character at the end of each
row, clearly its a newline or ENTER character.. I have tried
dos2unix.exe, a perl program that converts dos files to unix,...
|
by: Megi |
last post by:
welcome,
I input data form file to mysql with command: load data local infile..
The efect is that the data are duplicated or trippled..etc with every re-loading the script, but I need to load...
|
by: Eric_Dexter |
last post by:
I am trying to take some data in file that looks like this
command colnum_1 columnum_2
and look for the command and then cange the value in the collum(word)
number indicated. I am under...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |