|
|
|
|
![]() ![]() |
Jan 25 2008, 01:52 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 248 Joined: 18-July 07 From: Slough (UK) Member No.: 46,682 |
Hi, when running a PHP script I keep getting the error:
QUOTE Notice: Undefined variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294 Notice: 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: CODE 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. |
|
|
|
Jan 25 2008, 12:07 PM
Post
#2
|
|
|
Ephesians 6:10-17 ![]() Group: [MODERATOR] Posts: 1,833 Joined: 22-June 05 From: The place where moving forward means moving backwards. Member No.: 8,528 ![]() |
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:
CODE 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. |
|
|
|
Feb 8 2008, 11:51 AM
Post
#3
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 8-February 08 Member No.: 57,551 |
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:
CODE 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. This post has been edited by DarAngel: Feb 8 2008, 12:11 PM |
|
|
|
Apr 8 2008, 05:25 AM
Post
#4
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 65 Joined: 7-April 08 From: Toronto, Canada Member No.: 60,502 |
This is for Dar Angel
If 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:::: CODE if(isset($bret)) { return $bret; } indtead of CODE return $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 |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 4th July 2008 - 10:51 PM |