mysql_connect('localhost','root','root') or die('remote server cant' connect');
mysql_select_db('www.111cn.net') or('selected not exists!');
$sql = "Select borough_thumb,id from fke_borough where borough_thumb'' and isnew =1 ";
$result = mysql_query( $sql ) or die(mysql_error());
$_path ='../upfile/';
//批量查询数据库中图片不为空的记录,并用file_exists与is_file进行图片进行分析是否存在网站指定目录
while( $rs = mysql_fetch_array( $result ) )
{
$t_file = $_path.$rs['borough_thumb'];
echo "查看";
if( isFile($t_file) )
{
echo '存在
';
}
else
{
updateSql($rs['id']);
echo '
',$rs['id'];
}
}
//更新数据库
function updateSql($fid)
{
mysql_query("Update fke_borough set borough_thumb='' where id='$fid' ") or die('update fail');
}
//用户判断文章是否存 is_file file_exists函数实现
function isFile($path)
{
if( file_exists($path) && is_file($path))
{
return true;
}
else
{
return false;
}
}
//注意is_file 与 file_exists函数不能判断绝对路径如我上面的$_path ='/upfile/'就会显示找不到文件,如果用../upfile/就OK了,
?>