mrdee 1 Report post Posted January 25, 2008 Hi, when running a PHP script I keep getting the error: Notice: Undefined variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294Notice: Undefined variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294(And, yes, I get it twice).The code related to the variable is as follows:function LogString($string,$type) { $t_log = "\n"; $t_log .= $this->globaldata->server_vars['REMOTE_ADDR']."|"; $t_log .= date("Y-m-d h:i:s A|"); $t_log .= "$type| "; $string = str_replace("\n","\\n",$string); $t_log .= $string; if($this->is_enabled) { $bret = $this->writeToFile($t_log); } $this->whole_log .= $t_log; return $bret; } I must stress that I did not write this code myself, but a program called 'Simfatic Forms' which I am Beta testing.Can anyone spot where the mistake might be?Thanks for any help I might get. Share this post Link to post Share on other sites
truefusion 3 Report post Posted January 25, 2008 I'm assuming $this->is_enabled is returning false. Since it's returning false, the bret variable will not be set. My only suggestion is to make the if statement have an else: if($this->is_enabled){$bret = $this->writeToFile($t_log);} else {$bret = FALSE;}And the only reason i can think of why the error appears twice is because the function LogString is be-ing called twice. I say all of this bearing ignorance of the rest of the script. Share this post Link to post Share on other sites
DarAngel 0 Report post Posted February 8, 2008 (edited) Yes as what the truefusion said I think that the script is reporting a notice that the String is null you can set the error reporting to: error_reporting(E_ALL ^ E_NOTICE); (add near the beginning of the script)This way you can continue to have the empty sting but you won't be told about it, I think that Notices shouldn't effect the functionality of your scripts. (I have notices turned off by default in my local PHP server environment)With the code the truefusion posted you can also clear the notice (I believe.) It all depends on your preference. Edited February 8, 2008 by DarAngel (see edit history) Share this post Link to post Share on other sites
dave2win 0 Report post Posted April 8, 2008 This is for Dar AngelIf the guy mrdee is Beta testing some thing then he should not turn Error Reporting off. This will keep the errors hidden and the program will come out as a faulty program. Beta Tersting should be always be done with Error Reporting settings changed to all.And for your problem (@mrdee)The function is returning $bret without checking it's existance. Just do a check if it's set or not using.Try & use this code:::: if(isset($bret)){return $bret;} indtead ofreturn $bret; I think it error is being given twice because the function is being called twice by some other func.This is all that i could think of.Dave Share this post Link to post Share on other sites