Okay, it isnt pretty, but it works - I had to fix the data variable coming through the while array loop in line, even tho it echos to the screen as
mysql insert errors occured when it tried to read the following text field:
'Look there, it's Mom's kids' - choking on the single quotes
MY php solution involved replacing ' with \' so that the variable would read
Mom\'s kids
however - it actually shows up in the database as
Mom's kids - THE CORRECT WAY.🙂
$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);
$fixname = str_replace($singlequote, "$slash", $data[1]);
$fixbrand = str_replace($singlequote, "$slash", $data[2]);
$fixcol = str_replace($singlequote, "$slash", $data[8]);
$fixkey = str_replace($singlequote, "$slash", $data[18]);
$fixldesc = str_replace($singlequote, "$slash", $data[20]);
$fixsdesc = str_replace($singlequote, "$slash", $data[19]);
$fixdir = str_replace($singlequote, "$slash", $data[21]);
$fixinga = str_replace($singlequote, "$slash", $data[22]);
$fixingi = str_replace($singlequote, "$slash", $data[23]);
$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]','$fixname','$fixbrand','$data[4]','$data[6]','$data[7]','$fixcol','$data[15]',
'$data[16]','$fixkey','$fixsdesc','$fixldesc','$fixdir','$fixinga','$fixingi','$data[25]','$data[27]',
'$data[28]','$data[29]')";
//echo $fixldesc."<br>";
mysql_query($import) or die("Insert of derm product list to table derm_product failed: ".mysql_error());
}
fclose($handle);