I'd like to parse a comma delimited text file that contains business names and addresses and then read each line into a mysql table. I've now been trying all sorts of tweaks but just can't seem to get it work.
The code actually reads and inserts the correct number of rows but no data is placed in the table other than the word "Array" in the BUSINESSNAME column.
Here's the code:
<?php
include("usersettings.inc");
mysql_select_db($mydb, $connection);
$fp = fopen ("marketing.csv","r");
while ($userinfo = fscanf ($fp, "%s\n")) {
list($businessname, $addressitem, $cityitem, $stateitem, $zipitem, $telephoneitem) = explode(",",$userinfo);
$sql = "INSERT INTO POOLHALLS SET BUSINESSNAME='$businessname',ADDRESS='$addressitem',
CITY='$cityitem', STATE='$stateitem', ZIP='$zipitem', TELEPHONE='$telephoneitem'";
$result=@($sql);
}
fclose($fp);
?>