Hi,
I am trying to use MySQL and PHP to upload a file using LOAD DATA INFILE command.. and I am having a lot of trouble with it, as everything goes fine but it just does not upload the data to the table from the file... here is what I am trying to do.. I know there is PHP in here, and I am on a MySQL forum, so please excuse for that.. but I have read everyone having so much problem with this.. so I thought that if someone has a solution then your help is highly appreciated.. as I have already spent 2 days on it... and still no where .. :(
what I am trying to do is load a text file to the DB server, empty the table if there is anything in it, and then I am trying to upload a text file that is there on the DB server, with the correct permissions.. I have tried using [LOCAL], I have tried changing all the permission issues, it is giving me an error stating that the DB user I am trying to connect with is not set up, BUT IT IS SET UP with all the permissions.. and I dont know what else to do to SET IT UP.. here is the code.. PLEASE HELP !!!
The LOAD DATA INFILE command that gets printed with the $sql query runs just fine on the command line.. but when done thru GUI {this way}, it does not upload the data.. to the table..
-------------------------------------------
<?
............................
// Set the temporary table name to write data to
$table_name = "test";
$query_truncate = "TRUNCATE TABLE $table_name";
mysql_query($query_truncate);
PRINT "Table has been emptied";
// Set-up query to load data from a set file
$textfile="$uploadfile";
print "This is the textfile value: $textfile <br>";
// ensure that $textfile is readable by all
chmod($textfile,0775);
print "File: $file <br>";
$command = ("scp /web/review/intranet/html/PONitika/".$file."
root@207.252.0.47:/fileuploads/posys/");
print ("$command <br>");
exec ($command);
//exec("echo 'Hello' > echoresult.txt");
$table_name = "test";
// it DOES NOT WORK AFTER THIS...
//==================================================
$query_load = "LOAD DATA INFILE '/fileuploads/posys/$file' INTO TABLE $table_name;";
mysql_query($query_load) or die (mysql_error());
// The above query when printed here works just fine on the command line //=======================================================
print "<br>$query_load";
?>
THANK YOU -