Re: Using MySQL Command Load Data Infile

From: Chris Hope (blackhole_at_electrictoolbox.com)
Date: 06/28/04


Date: Mon, 28 Jun 2004 15:53:38 +1200

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/


Relevant Pages

  • Breaking from MySQL to Linux system (SQL Injection).
    ... found a Mysql Injection based in error response. ... I'm able to explore it using a query like this one: ... of all .php file he upload. ...
    (Pen-Test)
  • mySQL connection limit
    ... connections are available per mySQL account or something like that. ... PHP file and as a result the above is not necessary. ... snippet too many times cause mySQL to prevent user "myself" from connecting ...
    (comp.lang.php)
  • PHP MySQL problems
    ... home machine (Winxp pro) ... I have got everything working now - I know MySQL works cos I am able to run ... php file IE returns the ... Parse error: ...
    (alt.php)
  • Re: Dateipath in Datenbank speichern
    ... kannst du einen String wie folgt zuweisen: ... Googlefutter: C# MySQL Escape ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • running PHP on Windows XP
    ... I installed Apache/MySQL/PHP on Windows XP. ... Microsoft IIS 4 or higher was defaultly selected for MySQL. ... When I double-click a PHP file, ... I want my PHP file to work on my browser offline just like uploading ...
    (comp.lang.php)