My data contains single quotes ' in the midst of text fields to be imported.
Fgetcsv is successfully stripping dual double quotes, but the import fails when it encounters a field with just one single quote.
as you can see, i have tried some tricks to remove the pesky characters with no luck, even using an if statement to set myself up to do something cool. I just dont know what that is.
how do I EASILY remove or suppress them please??
$handle = fopen("ds/tb_product.csv", "r");
while (($data = fgetcsv($handle, 10000, ",")) !== FALSE)
{
//prod_long_description add back into list after debugging after prod_short_description
// $fixdesc = str_replace($singlequote, $space, $test);
$quotepos = strpos($data[20], $singlequote);
if ($quotepos != 0) {
$import="INSERT into derm_product(id, prod_name,prod_brand_name,prod_upc,prod_size,prod_measure,prod_color,prod_stock,prod_ordered,
prod_keywords,prod_short_description,prod_long_description,prod_direction,prod_ingredients_active,prod_ingredients_inactive,
prod_price,prod_msrp_price,prod_ds_brand_id,prod_url)
values('$data[0]','$data[1]','$data[2]','$data[4]','$data[6]','$data[7]','$data[8]','$data[15]',
'$data[16]','$data[18]','$data[19]','$data[20]','$data[21]','$data[22]','$data[23]','$data[25]','$data[27]',
'$data[28]','$data[29]')";
echo $fixdesc."<br>";
echo "|".$singlequote."|<br>";
echo "|".$space."|<br>";
$fixdesc = str_replace($singlequote, $space, $data[20]);
mysql_query($import) or die("Insert of derm product list to table derm_product failed: ".mysql_error());
}
}
fclose($handle);