MyBB Community Forums

Full Version: Notice: Undefined variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Fresh install, php 4.3.7 gives me a big pile of undefined variables.

You can look if you would like
This is due to a fair amount of sloppy coding that is still present in MyBB. To fix for now, you can edit

./global.php and
./admin/global.php

And add:

Code:
error_reporting(E_ALL ^ E_NOTICE);

Under:

Code:
/**
* MyBulletinBoard (MyBB)
* Copyright � 2004 MyBulletinBoard Group, All Rights Reserved
*
* Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*
*/

Chris.
Sad I had that fix but turn off error messages isn't really a good way to go about with bug fixes lol.
Well, if you've seen some of the latest announcements about RC3, you'll see that the code cleanup is ongoing and not quite finished yet. When it is completed, you won't necessarily have to turn down error reporting to avoid these errors. Wink
J2000_ca Wrote:Sad I had that fix but turn off error messages isn't really a good way to go about with bug fixes lol.
According to the PHP Manual:
Quote: E_NOTICE (integer) Run-time notices indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.
Quote:Note: Enabling E_NOTICE during development has some benefits. For debugging purposes: NOTICE messages will warn you about possible bugs in your code. For example, use of unassigned values is warned. It is extremely useful to find typos and to save time for debugging. NOTICE messages will warn you about bad style. For example, $arr[item] is better to be written as $arr['item'] since PHP tries to treat "item" as constant. If it is not a constant, PHP assumes it is a string index for the array.
My point was that they aren't bugs just because PHP reports the notices... If I were to do something such as...
<?php
$test['a'] = '1';
$test['b'] = '2';
$test['c'] = '3';
if ($test['d']) echo 'd exists!';
?>
PHP would return a notice. Why? Because $test['d'] doesn't exist, but obviously that is what was being checked for so it's not a bug. MyBB, in my opinion, does not need to be able to run with E_NOTICE enabled. (yes, I know array_key_exists could do this check without returning notices but doesn't exist in all versions of PHP 4)
I tried adding the fix at the top of the page to the 2 global.php files but I'm still getting all the Notice:undef. variable messages.Anybody got any further suggestions I have used the RC4 version as well - still the same problem.
Yea I do.
yes,that's what I'm getting- do you have a way to get rid of them?
I sorted it by putting the fix in the install/index php file. I'm up and running now
Pages: 1 2