Re: Can't Load Data into Mysql Using PHP
| From: | David Robley | Date: | Tue, 30 Apr 2002 10:40:17 +0000 |
| Subject: | Re: Can't Load Data into Mysql Using PHP | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18897@lists.php.net to get a copy of this message | ||
In article <20020430055251.85053.qmail@pb1.pair.com>,
nedcor4@nedcor.com.hk says...
> Dear all
> I had a problem to get the php to load a csv file into mysql.
> I had a csv file which located at my HDD, and i had tried to Import the data
> from this CSV file into mysql using MYCC which is a console program for
> mysql, it successfully load the data into mysql table.
> Now i try to setup my webpage, which tried to perform same task is to load
> that csv file's data into mysql table, but it won't work!! don't know why!!
> here is my php code.
>
> <?
> 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);
> }
> ?>
>
> when i run this script, it doesn't load the data into mysql! but as i said
> before, using the same query in MYCC, i can successfully load the data into
> Mysql database.
>
> Could someone pls tell me what mistake i had made?
1) Is the value of $select correct so that the if statement gets
executed?
2) If so, use mysql_error() after your mysql_query() to see if an error
is returned by mysql.
3) Where is the value of $result coming from? Do you mean
$resultimportquery?
--
David Robley
Temporary Kiwi!
Quod subigo farinam