Jump to content

Why is it null or no value?


dlmaster

Recommended Posts

...
while (read from directory)
{
<tr>
<td valign="middle" align="center"><img src="<?php echo $dir.$f ?>" border="0" /></td>
<td valign="middle" align="center"> <input type="checkbox" name="delete[]" value="<?php echo $filename ?>"> </td></tr>

<?php 
increment the counter;
}
closedir( $dir ); 
?>

This the code where I display the thumbnails for user to delete them.. and below is the the code to delete the files...

 

if((isset($_REQUEST['delete2'])) && (!empty($_REQUEST['delete2'])) )
{   $name = $_REQUEST['name'];
$address = $_REQUEST['address'];	
$id= $_REQUEST['usr']; 
$add= $_REQUEST['add'];
print_r($_REQUEST);
    foreach($_REQUEST['delete2'] as $file) 
    { echo $file;
    	$fstring = substr($file, 0, -3); 
    	$fext = substr($file, strrpos($file, '.')+1 );
    	$f= $fstring.$fext; 
        echo 'Deleting file [' . $f . '] ... '; 
      
        some delete sql statement
      
        unlink ($name."/".$address.'/'.$f);
        unlink($name."/".$address.'/thumb/'.$f); 
        echo 'Done!<br />'; 
       echo '<meta http-equiv="refresh" content="4;url=home.php?usr='.$id.'&addr='.$add.'">'; 
    } 
} 

 

My question is why after pressing the delete button (submit the form), I cannot get the value of $file.

After I press the delete button, it will show me :

 

Array ( [usr] => 4 [addr] => test [delete2] => Array ( [0] => [1] => ) [address] => 3 [name] => li [add] => test [phpSESSID] => 407518078be038c4babd9e7446da5ca7 ) Deleting file [] ...

 

Please help me... I have used this code in somewhere else in other pages. It worked.. Thank you in advance..

Link to comment
Share on other sites

Are you sure that the checkboxes have any value in the form? It also appreas that in your form there you have delete[] as the value, while you are referring to delete2 in your code.

 

Also, It's better if you post the actual code and not pseudocode. The error may where you don't expect it to be, but it's hard to point it out, if you only post what you think is significant.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.