<?php
//调用数据库配置文件
require ("data/common.inc.php");
//链接数据库
$conn = mysql_connect($cfg_dbhost, $cfg_dbuser, $cfg_dbpwd) or die("服务器链接失败");
mysql__db($cfg_dbname) or die("打开失败");
//如果是gbk格式 改成 mysql_query("SET NAMES gbk");
mysql_query("SET NAMES UTF8");
$sql = "select * from {$cfg_dbprefix}addonarticle order by aid desc";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)) {
$body = $rows["body"];
//正则替换所有链接
$newbody = preg_replace("/<a(.*)>(.*)</a>/is", "$2", $body);
$sqlu = "update {$cfg_dbprefix}addonarticle set body='" . $newbody . "' where aid=" . $rows["aid"];
$resultu = mysql_query($sqlu);
if (!$resultu) {
$eoo[] = $rows["aid"];
}
}
if (isset($eoo)) {
echo "有错误,有错误的ID如下:<br/>";
print_r($eoo);
} else {
echo "执行成功";
}
?>
|