Jump to content

Notice: Undefined variable not sure why.


samtwilliams

Recommended Posts

Can anyone enlighten me as to why i get: Notice: Undefined variable: global_error_reporting in C:\wamp\www\inc\settings.php on line 35.

 

//error handler function
function customError($errno, $errstr)
  {
if ($global_error_reporting == 0) {
} elseif ($global_error_reporting == 1) {

	 $myFile = $www_location."inc\error_log.txt";
	$fh = fopen($myFile, 'a') or die("can't open file"); 
	$stringData = "Error: [$errno] $errstr 
	";
	fwrite($fh, $stringData);
	fclose($fh);
} elseif ($global_error_reporting == 2) {
	echo "<b>Error:</b> [$errno] $errstr";
} elseif ($global_error_reporting == 3) {
	$myFile = $www_location."inc\error_log.txt";
	$fh = fopen($myFile, 'a') or die("can't open file"); 
	$stringData = "Error: [$errno] $errstr 
	";
	fwrite($fh, $stringData);
	fclose($fh);
	echo "<b>Error:</b> [$errno] $errstr";	
}

  }

 

The variable is set further up the page.

 

Thanks

Sam

Link to comment
Share on other sites

It means that you haven't actually set a value to it before trying to use the value in a statement.

 

Was this supposed to be a global variable?

 

If yes, you need to tell PHP this.

<?php function customError($errno, $errstr)
{
    global $global_error_reporting; // Tell PHP to look in the global scope rather than local.
    ...
}

 

~juddster

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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