Problem on Load CSV file to Mysql through PHP Script

From: Date: Fri, 26 Apr 2002 09:39:33 +0000
Subject: Problem on Load CSV file to Mysql through PHP Script
Groups: php.general 
Request: Send a blank email to php-general+get-94711@lists.php.net to get a copy of this message
Dear all I had a problem which trying to load data to Mysql Table, Here is my code in my HTML: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=big5"> </head> <body bgcolor="#FFFFFF" text="#000000"> <? include 'phpstudy/constant.inc'; $link=mysql_pconnect(HOST,USER,PASSWD); mysql_select_db(DBNAME,$link); print ($select); if ($select =="HKD RATE") { $importquery= "LOAD DATA LOCAL INFILE 'C:\\Documents and Settings\\jack\\Desktop\\Web\\test\\hkd_rate.csv' into hkd_depsit1 fields terminated by ','"; $resultimportquery=mysql_query($importquery,$link); print ($result); } ?> </body> </html> The code above is to see if the variable passed from other form($select) is "HKD RATE" or not , if it is, then it will call Mysql to perform LOAD DATA from a csv to hkd_deposit1 table. As the result comes out that the mysql didn't do any thing at all, it doesn't import the data from hkd_rate.csv to hkd_deposit1. I had tested using different query , which change the 'importquery' to "delete from hkd_deposit" in php, by using this as the query, it works!It did delete all the record from hkd_deposit table! I had test the query in myCC program which design for MYSQL Operation, it can successfully import the csv file into table, but i don't know why it won't work with php script! Pls give advice see if i got anything wrong in php! -- Thx a lot! Jack nedcor4@nedcor.com.hk

« previous php.general (#94711) next »