PHP检查MySQL附件是否失效

<?
header("Content-Type:text/html; charset=utf-8");
//$pagesize = 5; //每页显示5条记录
$hostname = "localhost"; //数据库地址
$username = ""; //用户名
$password = ""; //密码
$db_name = ""; //数据库名;
?>

<?php
//连接MySQL数据库
$conn = mysql_connect($hostname,$username,$password) or die("无法连接数据库!");
mysql_select_db($db_name);
$sql = 'SELECT * FROM `boblog_upload`'; //查询表
$result = mysql_query($sql,$conn);
//echo mysql_num_rows($result);
while($rs= mysql_fetch_array($result)) {
//echo $rs['fid'],' ',$rs['filepath'],' ';
if (@fopen('../'.$rs['filepath'],'r')) {
echo $rs['filepath'].' <font color="blue">文件存在</font> <br />';
$Y_fid[] = $rs['fid'];
} else {
echo $rs['filepath'].' <font color="red">文件不存在</font> <br />';
$N_fid[] = $rs['fid'];
}
}
foreach ($Y_fid as $fid) {
//echo '<font color="red">FID有效列表!</font> <br />';
//echo $fid;
}
foreach ($N_fid as $del) {
//echo '<font color="red">FID失效!</font> <br />';
//echo $del;
$delfid = 'DELETE FROM `boblog_upload` WHERE `boblog_upload`.`fid` = '.$del;
echo $delfid,'<br />';

}
?>

评论列表

此文章还没有评论。