I insert data into table as bulk upload, $handle = fopen($_FILES['file_clg']['tmp_name'], "r");
fgetcsv($handle);
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$collegename = trim(str_replace(array("’","'"),"'",$data[0]));
$description = trim(str_replace(array("’","'"),"'",$data[1]));
$sql1 = $db->selectquery("insert into $tbl(name,details)values('" .$collegename."','" .$description."')");
}
fclose($handle);
Only two fields is mentioned here: morethan 25 columns in my bulkupload csv
The problem is that the csv delimiter is the comma (',') but in some cases 'details' field contents include commas, as in this case record not inserted properly..
how to solve this case???
And a problem in insertion section,
College name : Alva’s Institute of Engineering & Technology (AIET)
and its saved in table as below format :
Alva�s Institute of Engineering & Technology (AIET)
I try below code:
$collegename = htmlentities(iconv("cp1252", "utf-8", trim(str_replace(array("’","'"),"'",$data[0]))), ENT_IGNORE, "UTF-8");
but its not working, how can i solve the issue in single quotes
And i placed : header("Content-Type: text/html; charset=ISO-8859-1");
into the header section..