<?php
mysql_select_db('tablo_adi', mysql_connect('localhost', 'root', '123456'));
function get_data($url){
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ref = "http://www.koeri.boun.edu.tr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_REFERER, $ref);
$fe = curl_exec($ch);
curl_close($ch);
return $fe;
}
function bosluk_sil($fe){
return str_replace(array("\n", "\r", "\t", " "), '', $fe);
}
$xml = bosluk_sil(get_data("http://www.koeri.boun.edu.tr/sismo/zeqmap/xmlt/son24saat.xml"));
$desen = '@<earhquakename="(.*?)"lokasyon="(.*?)"lat="(.*?)"lng="(.*?)"mag="(.*?)"Depth="(.*?)"/>@';
preg_match_all($desen, $xml, $fe);
$name = $fe[1];
$lokasyon = $fe[2];
$lat = $fe[3];
$lng = $fe[4];
$mag = $fe[5];
$depth = $fe[6];
$say = count($name);
for($i=0; $i<$say-1; $i++){
$ekle = mysql_query("insert into tablo_adi (name, lokasyon, lat, lng, mag, depth) values ('$name[$i]', '$lokasyon[$i]', '$lat[$i]', '$lng[$i]', '$mag[$i]', '$depth[$i]')");
if($ekle){
echo "<font color='green'>Eklendi</font><br/>";
}else{
echo "<font color='red'>".mysql_error."</font><br/>";
}
}
?>localde sorunsuz çalıştı.
http://i.imgur.com/IthpS6o.jpg