Hi I have the following piece of code which is supposed to upload a csv file and add the information to the database. even though it gets to the echo import complete no data is being added to the table.
copy($_FILES["fileCSV"]["tmp_name"],"shotdev/".$_FILES["fileCSV"]["name"]); // Copy/Upload CSV
$objCSV = fopen("shotdev/".$_FILES["fileCSV"]["name"], "r");
while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) {
$strSQL = "INSERT INTO customer_list ";
$strSQL .="(company_name,website,owner,email_addredd,client_id) ";
$strSQL .="VALUES ";
$strSQL .="('".$objArr[0]."','".$objArr[1]."','".$objArr[2]."' ";
$strSQL .=",'".$objArr[3]."','".$objArr[4]."','".$objArr[5]."') ";
$objQuery = mysql_query($strSQL);
}
fclose($objCSV);
echo "Import completed.";
This is my table structure
customer_list` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`company_name` varchar(100) NOT NULL,
`website` varchar(100) NOT NULL,
`owner` varchar(100) NOT NULL,
`email_addredd` varchar(200) NOT NULL,
`client_id` int(10) NOT NULL,
PRIMARY KEY (`id`)
)