Recent Topics

Undefined Index error

Started by on Jun 11, 2004 – Contents updated: Jun 11, 2004

Jun 11, 2004 21:52    

I've installed b2evolution on my personal machine, which is running Winodows 2000 and IIS 5.0. It runs almost completely, except I get the following errors on every blog and the index.php login:

Notice: Undefined index: SCRIPT_FILENAME in c:\inetpub\wwwroot\blog\skins\custom\_bloglist.php on line 8

Any idea how to fix this?

JP

Jun 11, 2004 22:10

JP,

We definitely do aim towards making b2evolution compatible with almost all versions of IIS, so I'm eager to solve the problem, as it may prevent others in the future.

1. What version of b2evolution are you using? I ask because we've recently updated the IIS support for this kind of thing.

2. Check this out:
http://forums.b2evolution.net/viewtopic.php?t=1412
Does the solution there solve your problem?

3. If you're still stumped, then open up
http://localhost/path/to/b2evolution/blogs/install/phpinfo.php
in your web browser. Look for any of the _SERVER environment variables that look like they're set to something like:
/path/to/b2evolution/blogs/install/phpinfo.php
Let us know which line this appears on. That'll help us prevent this in the future, if it's a case we're not already testing for.

Jun 11, 2004 22:18

Whoops!

Just realized, we use $_SERVER['SCRIPT_NAME'] in other places, too!

This will have to be reworked a bit, it seems. We may want to set this environment var when finding the $ReqPath, if it's missing.

I'll post updates here.

[EDIT]:
Whoops, we're talking about $_SERVER['SCRIPT_FILENAME'], which is used in almost all of the skin files, not $_SERVER['SCRIPT_NAME'] which is only used once, and won't generate an error if its not set.

Jun 12, 2004 04:03

Open up your php.ini file in your favorite text editor. (By default, this will reside at C:\windows\php.ini.)

Search for this term
error_reporting

I'm guessing that's set to display notices, yes?

That line is there to try to prevent people from going directly to the skin templates, but lacking it is not really a problem. It just means that you'll usually see a blank page or an error message rather than "Please, do not access this page directly."

I recommend setting your error_reporting directive to something less strict.

http://www.php.net/manual/en/ref.errorfunc.php wrote:

error_reporting integer

Set the error reporting level. The parameter is either an integer representing a bit field, or named constants. The error_reporting levels and constants are described in Predefined Constants, and in php.ini. To set at runtime, use the error_reporting() function. See also the display_errors directive.

In PHP 4 and PHP 5 the default value is E_ALL & ~E_NOTICE. This setting does not show E_NOTICE level errors. You may want to show them during development.

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.

Note: In PHP 5 a new error level E_STRICT is available. As E_STRICT is not included within E_ALL you have to explicitly enable this kind of error level. Enabling E_STRICT during development has some benefits. STRICT messages will help you to use the latest and greatest suggested method of coding, for example warn you about using deprecated functions.

In PHP 3, the default setting is (E_ERROR | E_WARNING | E_PARSE), meaning the same thing. Note, however, that since constants are not supported in PHP 3's php3.ini, the error_reporting setting there must be numeric; hence, it is 7.

Jun 15, 2004 17:38

Isaac,

I changed my php.ini file's error reporting to:

E_ALL & ~E_NOTICE

This gets rid of the error messages on the blog. My questions are:

Is the message I received important or not?
Can I safely ignore it now?
What exactly was/is going on?
Will the error affect the operation in any meaningful way?

thanks!
JP

Jun 16, 2004 22:01

The message is not important, really.. it's just a check if the file has been called directly.
With 0.9.0.8 this is fixed.
It tried to check the $_SERVER array's SCRIPT_FILENAME value. This is normally the filename of the running script. But in your case it was not set and therefor the notice.
The check was simply to check if the running script (SCRIPT_FILENAME) had a '_' as first character, which means that it's a file that's not meant to be called directly, like _archives.php.

HTH.

Mar 28, 2006 20:30

I was having this same problem. this is what I did to fix it.

FYI to fixt this I changed This

if(substr(basename($_SERVER['SCRIPT_FILENAME']),0,1)=='_')
		die("Please, do not access this page directly.");

to this

	if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

My problems are gone. It was not a problem with B2E but with my skin I was using. I customized my skin, so I did not want to update it.


Form is loading...

b2evolution CCMS – This forum is powered by b2evolution CMS, a complete engine for your website.