LOAD DATA LOCAL INFILE- problem uploading text file to dB!


#1

Hello again,

I own a business that is highly dependent on the statistics I load to my dB everyday. Unfortunately on 5/19, my Web Hoster went live w/ PHP Version 4.3.6 and as you seasoned veterans know, one of the security patches in this version is the disabling of LOAD DATA LOCAL INFILE.

Now, the simple procedure I used to use no longer works, and the result is that when I try to upload my statistics (the foundation of my service!) I get the following error message:

Error
SQL-query :
LOAD DATA LOCAL INFILE ‘/tmp/phpzc76n9’ INTO TABLE statstable FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘rn’
MySQL said:
The used command is not allowed with this MySQL version

I’ve done alot of research and have found a wealth of info on the subject. The problem is that I’ve now been down for 2 days trying to find a “fix” that will allow me to perform this simple upload once again. My customer complaints are mounting and I have gotten no help from my WebHoster.

Does anyone know what I can do to upload a simple “.txt” file from my machine to the host server running this version of php??? I am in dire need of some direction and would greatly appreciate any help you can offer! THANK YOU!!!

p.s. Carella, my friend…got any ideas???


#2

Well, I have been looking around for a possible fix for you. Seems the latest version of MySQL has this problem sorted.

However, check out this thread:

http://beta.experts-exchange.com/Databases/Mysql/Q_20799075.html

Maybe thats off some use. Scroll down for some possible solutions.


#3

You might also want to check out phpMyAdmin (http://www.phpmyadmin.net/home_page/) Once you’ve got it configured for your use, you can Insert data from a textfile into table.

Alternatively, it shouldn’t be too difficult to write a script that will fgets() each line of a file, then use that as a sql_query.

Maybe something like this:
[php]<?php
$dbhost = “localhost”;
$dbuser = “user”;
$dbpass = “passwd”;
$dbname = “mydb”;
require_once(‘DB.php’ ); // get this from http://pear.php.net
$dblink = DB::connect(“mysql://$dbuser:$dbpass@$dbhost/$dbname”);
$handle = fopen("/tmp/inputfile.txt", “r”);
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$result = $dblink->query($buffer);
}
fclose($handle);
?>[/php]