作者:逢源堂_344 | 来源:互联网 | 2023-09-24 20:26
error_reporting("E_ALL^E_NOTICE");
//default_charset("utf-8");
mysql_connect("localhost","root","****");
mysql_select_db("test");
mysql_query("set names 'UTF8'");
$reg="#
·(.*)#iUs";
$con=file_get_contents("http://it.sohu.com/7/1002/17/column203661721.shtml");
iconv("GBK","UTF_8//IGNORE",$con);
preg_match_all($reg,$con,$matches);
//var_dump($matches);
foreach($matches[1] as $id=> $d )
{
$sql="INSERT INTO tmp(id,title,url )VALUES('NULL','".$matches[2][$id]."','".$d."')";
//echo $sql."
";
//echo $matches[2][$id]."
";
mysql_query($sql);
//echo $d;
}
插入之后,中文显示乱码,已经转码了,为什么还这样、、、??
?>