[php]
$dbhost = “…”; //the name of your host, for example “example.com”
$dbuser = “…”; //your database username
$dbpass = “…”; //your database password
$dbname = “…”; //the name of the database you are accessing
//this connects to mysql
$dbconnection=mysql_connect($dbhost, $dbuser, $dbpass);
//if it cannot make a connection then the mysql error is shown
if (!$dbconnection) {
die('Could not connect: ’ . mysql_error());
}
//this selects the correct database
$db_selected=mysql_select_db($dbname, $dbconnection);
$lines = file(‘ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/KEMT.TXT’);
$top_line = $lines[0];
$bottom_line = $lines[1];
mysql_query(“INSERT INTO tbl_example (top_line, bottom_line) VALUES(’$top_line’,’$bottom_line’)”);
[/php]