Kal
12-21-2006, 11:35 AM
Guys
i have a script which you can view below that will import a .csv file into a mysql table, however i get errors due to the various special characters in the spreadsheet. is there anyway i can get around this.
<?php
$fs = filesize("file.csv");
$fh = fopen("file.csv", "r");
fgets($fh, $fs);
require ('db.php');
while($row = fgetcsv($fh, $fs))
{
$category_id = $row["0"];
$category = $row["1"];
$manufacturer_id = $row["2"];
$manufacturer = $row["3"];
$product_name = $row["4"];
$info_text= $row["5"];
$features= $row["6"];
$specification = $row["7"];
$image_name = $row["8"];
$data_sheet = $row["9"];
$buy_price = $row["10"];
$query = "INSERT into test.test (category_id, category, manufacturer_id, manufacturer, product_name, info_text, features, specification, image_name, data_sheet, buy_price) values ('$category_id', '$category', '$manufacturer_id', '$manufacturer', '$product_name', '$info_text', '$features', '$specification', '$image_name', '$data_sheet', '$buy_price')";
$result = mysql_query ($query) or die (mysql_error());
}
?>
thanks in advance
i have a script which you can view below that will import a .csv file into a mysql table, however i get errors due to the various special characters in the spreadsheet. is there anyway i can get around this.
<?php
$fs = filesize("file.csv");
$fh = fopen("file.csv", "r");
fgets($fh, $fs);
require ('db.php');
while($row = fgetcsv($fh, $fs))
{
$category_id = $row["0"];
$category = $row["1"];
$manufacturer_id = $row["2"];
$manufacturer = $row["3"];
$product_name = $row["4"];
$info_text= $row["5"];
$features= $row["6"];
$specification = $row["7"];
$image_name = $row["8"];
$data_sheet = $row["9"];
$buy_price = $row["10"];
$query = "INSERT into test.test (category_id, category, manufacturer_id, manufacturer, product_name, info_text, features, specification, image_name, data_sheet, buy_price) values ('$category_id', '$category', '$manufacturer_id', '$manufacturer', '$product_name', '$info_text', '$features', '$specification', '$image_name', '$data_sheet', '$buy_price')";
$result = mysql_query ($query) or die (mysql_error());
}
?>
thanks in advance