Halting
04-09-2006, 05:50 PM
Hey,
For the past few days I've given my visitors the ability to delete multiple documents from their folder. Only recently did I realise it isn't working anymore and now it's driving me nuts. Here is the basis markup:
<?php
include("t.php");
include("u.php");
$fetchimages = mysql_query("SELECT * FROM iuplogs WHERE username = '$_SESSION[username]' ORDER BY id DESC");
?>
<form method="post" name="form">
<table width="100%" cellpadding="0" cellspacing="0">
<?
if ($_POST['delete']) {
foreach ($_POST['delete'] as $value) {
mysql_query("DELETE FROM iuplogs WHERE id = '$value'");
$fetchdelete = mysql_fetch_array(mysql_query("SELECT * FROM fuplogs WHERE id = '$value' ORDER BY id DESC LIMIT 1"));
$explode = explode("/", $fetchdelete[url]);
$filetodelete = "urs/$explode[4]";
$delete = unlink($filetodelete);
header("location: $url");
}
}
?>
<tr>
<td style="padding: 4px; padding-left: 12px;"><b>My Images</b></td>
</tr>
<?
while ($image = mysql_fetch_array($fetchimages)) {
?>
<tr>
<td><input type="checkbox" name="delete[]" value="<?=$image[id];?>"></td>
</tr>
<?
}
?>
</tr>
<tr>
<td align="right" style="padding-top: 5px;"><input type="button" value="Select All" onClick="this.value=check(this.form)" name="selectsq" /><input type="submit" value="Delete Selected" name="submit" /></td>
</tr>
</table>
</form>
<?
include("b.php");
?>
I really can't see any problem with this. For the record, here is the error message which I receive when I select "Delete Selected".
Warning: Invalid argument supplied for foreach() in /home/urload/public_html/test.php on line 10
If I didn't mark any checkboxes then I would understand why I receive this error, but even when I do select one or more checkbox(s) I still receive this. Previously, I used error_reporting(E_ERROR); to hide the message if they selected "Delete Selected" without marking a checkbox.
Any help would be very appreciated.
Thanks in advance,
mynameisoli
For the past few days I've given my visitors the ability to delete multiple documents from their folder. Only recently did I realise it isn't working anymore and now it's driving me nuts. Here is the basis markup:
<?php
include("t.php");
include("u.php");
$fetchimages = mysql_query("SELECT * FROM iuplogs WHERE username = '$_SESSION[username]' ORDER BY id DESC");
?>
<form method="post" name="form">
<table width="100%" cellpadding="0" cellspacing="0">
<?
if ($_POST['delete']) {
foreach ($_POST['delete'] as $value) {
mysql_query("DELETE FROM iuplogs WHERE id = '$value'");
$fetchdelete = mysql_fetch_array(mysql_query("SELECT * FROM fuplogs WHERE id = '$value' ORDER BY id DESC LIMIT 1"));
$explode = explode("/", $fetchdelete[url]);
$filetodelete = "urs/$explode[4]";
$delete = unlink($filetodelete);
header("location: $url");
}
}
?>
<tr>
<td style="padding: 4px; padding-left: 12px;"><b>My Images</b></td>
</tr>
<?
while ($image = mysql_fetch_array($fetchimages)) {
?>
<tr>
<td><input type="checkbox" name="delete[]" value="<?=$image[id];?>"></td>
</tr>
<?
}
?>
</tr>
<tr>
<td align="right" style="padding-top: 5px;"><input type="button" value="Select All" onClick="this.value=check(this.form)" name="selectsq" /><input type="submit" value="Delete Selected" name="submit" /></td>
</tr>
</table>
</form>
<?
include("b.php");
?>
I really can't see any problem with this. For the record, here is the error message which I receive when I select "Delete Selected".
Warning: Invalid argument supplied for foreach() in /home/urload/public_html/test.php on line 10
If I didn't mark any checkboxes then I would understand why I receive this error, but even when I do select one or more checkbox(s) I still receive this. Previously, I used error_reporting(E_ERROR); to hide the message if they selected "Delete Selected" without marking a checkbox.
Any help would be very appreciated.
Thanks in advance,
mynameisoli