I'm building an e-commerce site, where the owner needs to be able to
upload a CSV file of product that gets inserted into mySQL.
Unfortunately, I think my Web host may have some functions turned off.
Is there some other ways I can try to do the following?
First, I'm using a form to upload a file. That works, but it sets the
file permissions to 600, and the PHP command "exec()" is disabled so I
can't chmod it as part of the script.
But that's OK I guess. I can still FTP the file up and change the
permissions to even 777 if need be. The real problem comes when trying
to do the insert:
$sql = "LOAD DATA INFILE
'/home/myaccount/public_html/data/item_test.csv' INTO TABLE
`tbl_temp_produ pload` FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES
TERMINATED BY '\r\n'";
$result = @mysql_query($s ql, $dbh) or $error_msg .= "<div
align=\"center\ " class=\"tah12Re dBold\">".mysql _error()."</div>";
I'm getting no error message, but it's not inserting either.
I can use phpMyAdmin to manually insert the file off my local PC, but I
just can't get it to do it from the file on the server.
Is there another way to do this? (No I can't give phpMyAdmin access to
the user.)
Thanks for any suggestions!
Liam
upload a CSV file of product that gets inserted into mySQL.
Unfortunately, I think my Web host may have some functions turned off.
Is there some other ways I can try to do the following?
First, I'm using a form to upload a file. That works, but it sets the
file permissions to 600, and the PHP command "exec()" is disabled so I
can't chmod it as part of the script.
But that's OK I guess. I can still FTP the file up and change the
permissions to even 777 if need be. The real problem comes when trying
to do the insert:
$sql = "LOAD DATA INFILE
'/home/myaccount/public_html/data/item_test.csv' INTO TABLE
`tbl_temp_produ pload` FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES
TERMINATED BY '\r\n'";
$result = @mysql_query($s ql, $dbh) or $error_msg .= "<div
align=\"center\ " class=\"tah12Re dBold\">".mysql _error()."</div>";
I'm getting no error message, but it's not inserting either.
I can use phpMyAdmin to manually insert the file off my local PC, but I
just can't get it to do it from the file on the server.
Is there another way to do this? (No I can't give phpMyAdmin access to
the user.)
Thanks for any suggestions!
Liam
Comment