I have problem to export my file from text file into MYSQL using different platform thru my PHP code.
My first test is using a web server(php code and text file is there) and MYSQL running on Window XP platform. Both server (application and database server) running on Windows XP . And it run successfully.
This is how I do it :
$filenameinteg='C:\phpdev\www\public\dataintegration\9-9-2004.txt';
$CSVFile =$filenameinteg;
mysql_query('LOAD DATA LOCAL INFILE "'.mysql_escape_string($filenameinteg).'" INTO TABLE stphdata FIELDS TERMINATED BY "||" (noadj,t_mohon,t_byradj,t_terimajpph,t_byrduti,t_endos,t_suratcara,status,agen,caw_jpph,caw_dutistem ,negeri,nilaian_jpph,nama_penilai,nilai_balasan,daerah);') or die('Error loading data file.<br>' . mysql_error());
BUT when I try to put my application on webserver running on Linux platform (the text file also in the Webserver),but the MYSQL is in Windows XP (platform) I change my code this way:
$querytoinsert="LOAD DATA LOCAL INFILE '/var/www/htdocs/epsem/9-9-2004.txt' INTO TABLE stphdata FIELDS TERMINATED BY '||' (noadj,t_mohon,t_byradj) LINES TERMINATED BY '\r\n'";
//echo "Query to Insert is : $querytoinsert";
//$result=mysql_query($querytoinsert);
if (!$result)
{
die('Invalid query:'.mysql_error());
}
else
{
echo "Success Loading Data";
}
when I run the code, this is what I get:
Query to Insert is : LOAD DATA LOCAL INFILE '/var/www/htdocs/epsem/9-9-2004.txt' INTO TABLE stphdata FIELDS TERMINATED BY '||' (noadj,t_mohon,t_byradj)
Invalid query:File '\var\www\htdocs\epsem\9-9-2004.txt' not found (Errcode: 2)
Is it because of the slash on directory? Why it change from '/' to '\' in the error message?
Has anyone know what my problem here??Or is there any different when we do it in Linux server?
TQ