| 
	
 | 
 Posted by matt on 11/12/06 02:23 
Pedro Graca wrote: 
> matt wrote: 
>  
>>Pedro Graca wrote: 
>> 
>>>matt wrote: 
>>> 
>>>>Yet the $download seems to pass into the function and display fine!! 
>>> 
>>>I'd have to take a look at your script to understand why. 
>>>Maybe tomorrow, no promises. 
>>> 
>> 
>>Thanks, I have added in the line you have put there, but it still just  
>>prints a blank space. I appreciate your help. 
>  
>  
> Increase the level reporting level of your script. 
> Add these two lines right after the first php opening tag 
>  
>     error_reporting(E_ALL); 
>     ini_set('display_errors', '1'); 
>  
> When you get it working, remove the lines. Better yet would be to set 
> error_reporting and related configuration stuff turned on for the 
> development machine and off for the server. 
>  
> At some point in your code you call email_admin(). 
> Are the variables $usrname and $usremail set at the time of the call? 
>  
>     echo '<pre>'; var_dump($usrname, $usremail), echo '</pre>'; 
>     email_admin($usrname, $usremail); 
>  
> When I trimmed your code to 50 lines (just the email_admin() and a few 
> ifs left from the original code, no `global` or $GLOBALS stuff), the 
> $usrname and $usremail variables were correctly set inside the 
> admin_email() function. 
>  
>     function email_admin($usrname, $usremail) 
>     { 
>         $usrname  = $GLOBALS["usrname"]; 
>         $usremail = $GLOBALS["usremail"]; 
>         $download = $GLOBALS["download"]; 
>  
> Huh? ??!?!?!?!? 
> Why are you copying from $GLOBALS to the function parameters? 
>  
> Sprinkle a few debugging lines throughout the code to find out what it 
> is doing with the `global` and $GLOBALS stuff. 
>  
> First define a function for easy debugging: 
>  
>     function debug(&$var, $line) { 
>       echo '<pre>', 'DEBUGGING line ', $line, ': '; 
>       print_r($var); 
>       echo '</pre>'; 
>     } 
>  
> Then use that function in relevant places in your code: 
>      
>     function email_admin($usrname, $usremail) 
>     { 
>         debug($usrname, __LINE__); 
>         $usrname = $GLOBALS["usrname"]; 
>         debug($usrname, __LINE__); 
>         // ... 
>     } 
>  
>  
> The code you posted is a big mess :( 
> I suggest you break it into (small) functions, stop relying on 
> register_globals, do not use $GLOBALS or global declarations at all. 
>  
 
 
I seem to have broken the script altogether now, and can't get it to  
work again. 
 
You may have an idea, all I am trying to do, is display a list of files  
in a directory, then send an email to the admin when one is downloaded.  
I didn't write this script from scratch, I found the code that did the  
download display on a website, then added the send email function to it  
myself. If you know of a better, simpler way to do it, I would be very  
much appreciative.
 
  
Navigation:
[Reply to this message] 
 |