i have managed to code this CSV file and it is working well..the only problem i am getting is the variable error on the form..i get this error ...Notice: Undefined variable: data in C:\xampp\htdocs\helper.php(527) : runtime-created function on line 22
how do i resolve the error? this
this my sample code...
<form enctype="multipart/form-data" method="POST" action="" >
CSV<input type="file" name="file" />
<input type="submit" value="submit" name="submit"/>
</form>
//connect to the database
$connect = mysql_connect("localhost","root","");
mysql_select_db("test",$connect); //select the table
if(isset($_POST['submit']))
{
//get the csv file
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
mysql_query("INSERT INTO f38uj_zhgooglemaps_markers (title, addresstext, published, baloon, icontype, mapid) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."',
'".addslashes($data[4])."',
'".addslashes($data[5])."'
)
");
}
} while ($data = fgetcsv($handle,1000,",","'"));
}
?>