utf8_encode
Hej er der en måde hvor jeg kan bruge utf8_encode på her i koden så den altid lægger utf-8 ned i databasen også selv om den møde en side med iso-8859-1 ??Kode:
<?php
// Connect to the database
include 'dbconfig.php';
include 'dbopen.php';
function page_title($url,$h_id) {
$page = @file_get_contents($url);
if (!$page) return null;
$matches = array();
if (preg_match('|<meta[^>]*description[^>]*content=\"([^>]+)\"|Ui', $page, $matches)) {
if(count($matches) > 0)
$description= $matches[1];
else
$description='';
echo '<table style="border:1px solid #033333;margin:5px;width:1000px"><tr><td>Meta Description:</td><td>LinkID='.$h_id.'<br>Host='.$url.'<br> '.$description.'</td></tr></table>';
mysql_query("UPDATE IGNORE hostlist SET text2Index = '$description' WHERE id = '$h_id' LIMIT 1");
}
}
$antal = mysql_result(mysql_query("SELECT COUNT(*) FROM hostlist"),0);
for($i = 1; $i < $antal; $i++){
$query = "SELECT id,hostname,port,text2Index,priority,httpstatus,reklame FROM hostlist WHERE id = $i LIMIT 1" ;
$result = mysql_query($query);
while (list($id,$hostname,$port,$text2Index,$priority,$httpstatus,$reklame)= mysql_fetch_row($result)){
if (page_title("http://$hostname",$id)){
}
}
//Pause på 1 sekund.
if(($i % 100) == 100){
sleep(1);
}
}
mysql_close($conn);
?>