我无法将文件与服务器文件夹取消链接。
错误警告:
mysql_fetch_array()期望参数1是资源,给定布尔值 在第4行。
PHP代码:
<?php
if($_GET['action'] = "deletelink" && !empty($_GET['id']) && is_numeric($_GET['id'])) {
$result = mysql_query("DELETE FROM books WHERE id='".mysql_real_escape_string($_GET['id'])."' ");
while ($a_row = mysql_fetch_array ($result) )
{
unlink("/home/me/public_html/upload/image/$a_row[image]");
}
mysql_query("DELETE FROM 1 WHERE fid='".mysql_real_escape_string($_GET['id'])."' ");
mysql_query("DELETE FROM 2 WHERE fid='".mysql_real_escape_string($_GET['id'])."' ");
mysql_query("DELETE FROM 3 WHERE fid='".mysql_real_escape_string($_GET['id'])."' ");
mysql_query("DELETE FROM 4 WHERE fid='".mysql_real_escape_string($_GET['id'])."' ");
}
答案 0 :(得分:1)
您的代码存在一些问题:
mysql_
函数DELETE
个问题(可以以某种方式合并吗?)$_GET['action'] = 'deletelink'
根本不是比较(并且总是如此,因为它是作业)。关于您的问题,您必须首先选择数据:
<?php
if($_GET['action'] == "deletelink" && !empty($_GET['id']) && is_numeric($_GET['id'])) {
// you need to fetch the result first!
$result = mysql_query("SELECT * FROM books WHERE id='".intval($_GET['id']);
while ($row = mysql_fetch_array ($result) )
unlink("/home/me/public_html/upload/image/{$row['image']}");
// here come your delete statements
}
答案 1 :(得分:0)
简单打印是否从数据库获取记录,如果您获得记录,是否获得文件路径...请参阅下面的打印代码=======&gt;
public BindingList Load()
{
Using(PeopleDbContext pdbc = new PeopleDbContext())
{
_return pdbc.People.Local.ToBindingList<Person>();
}
}