<?php

// edit with personal settings
$location = ' ';
$username = ' ';
$password = ' ';
$database = ' ';

// csv to open
$file = ' .csv';

// connect to database
mysql_connect($location, $username, $password)
	or die("Error connecting to mysql: " . mysql_error());
mysql_select_db($database)
	or die("Error connecting to database: " . mysql_error());

// insert data from csv into database
if (($handle = fopen($file, "r")) !== FALSE) {
	while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
		$lat=str_replace("N ", "", $data[0]);
		$lon=str_replace("E ", "", $data[1]);
		$sgnl=str_replace("'", "", $data[2]);
		$query=mysql_query("INSERT INTO gheat_meting (lat, lng, signaal) VALUES ('$lat','$lon','$sgnl')");
		if (!$query) {
			die('Invalid query: ' . mysql_error());
		}
	}
	fclose($handle);
}

echo 'done';

?>
