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
https://forums.phpfreaks.com/topic/91507-why-is-it-null-or-no-value/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.