warnings on Windows NT4.0

Posted by Wuliao on Mon 18 Feb 2002 04:55 AM — 9 posts, 37,053 views.

#0
Nick,

I tried to install the forum on my home PC, which is running windows NT4.0 server. I almost got everything setup by following the instructions in the install.txt.

But when I pull up the logon.php, I got a full page of warnings. I just wonder if you have any quick suggestion how can I turn it off.

The IE version I was using is 5.5. The web server is running on MS IIS server 4.0.

The warnings messages are

Warning: Undefined index: session in D:\forum\include\common.php on line 204

Warning: Undefined index: session in D:\forum\include\common.php on line 206

Warning: Undefined index: session in D:\forum\include\common.php on line 208

Warning: Undefined index: adminaction in D:\forum\include\common.php on line 214

Warning: Undefined index: username in D:\forum\include\common.php on line 215

Warning: Undefined index: password in D:\forum\include\common.php on line 216

Warning: Undefined index: token in D:\forum\include\common.php on line 285

Warning: Undefined index: token in D:\forum\include\common.php on line 287

Warning: Undefined index: token in D:\forum\include\common.php on line 289

Warning: Undefined index: action in D:\forum\include\common.php on line 295

Warning: Undefined index: username in D:\forum\include\common.php on line 298

Warning: Undefined index: password in D:\forum\include\common.php on line 302

Thanks for any insight in advance.

Wuliao
Australia Forum Administrator #1
I presume the first warning is from this line:


$adminsession = $HTTP_POST_VARS ['session'];


I guess this is caused by the variable 'session' not being recognised as part of the POST variables. Why, I am not sure, as I would have thought that such variables could be unsupplied.

Which version of PHP are you using? Perhaps it is either:

  • Out of date, in which case you need to upgrade; or
  • Very recent, giving warnings that I don't get.


Apart from the warnings, does it work as expected? If so, it might just be a warning level that needs tweaking.
#2
After some research, it looks like to me that PHP got updated, and the warning message are new.

Anyway, here is the change I made to make the warnings disappear in the common.php

if (array_key_exists("session", $HTTP_POST_VARS))
$adminsession = $HTTP_POST_VARS ["session"];
if (empty ($adminsession) && array_key_exists("session", $HTTP_GET_VARS))
$adminsession = $HTTP_GET_VARS ["session"];
if (empty ($adminsession) && array_key_exists("session", $HTTP_COOKIE_VARS))
$adminsession = $HTTP_COOKIE_VARS ["session"];


The check on array_key_exists will make the warnings gone.

Thanks
Australia Forum Administrator #3
Sounds a bit wordy. You could change the error reporting level.

From the PHP web documentation:


E_NOTICE
Notices are not printed by default, and indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. For example, trying to access the value of a variable which has not been set, or calling stat() on a file that doesn't exist.


Also a comment:


"Default php.ini does NOT set to display E_NOTICE messages. For several reasons, programmers are better to work with NOTICE messages while developing PHP application."


Sounds like you have it set somehow.

You could find the php.ini file and try to set it to not display E_NOTICE, which should make the warnings go away.

Alternatively, change the error reporting level like this:


error_reporting(E_ALL & ~(E_NOTICE));



#4
I put the line in the common.php, and it works nicely.

And the forum also works fine after I configure the forum.

Thanks very much, nick.
Australia Forum Administrator #5
Let me know the URL when you have it going so I can try it. :)

There is a slightly more up-to-date version available, for instance the later one shows the number of views at the main (top) level, and at the summary per section (see this forum for an example).

Let me know if you would like a copy.
Amended on Tue 19 Feb 2002 06:20 AM by Nick Gammon
#6
I would like you to visit it if I could. The problem is machine only use telephone dialup, and did not have a fix IP. It is a really home PC.

For the time being, I am quite satisfied with the forum. I will see if I want try the newer one after I get used to this version.

Thanks a lot.
#7
It seems like to me the forum is not compatible with international language support, in particular support of chinese.

But if I change all the htmlentity function calls to htmlspecialchars function calls it then works fine.
Australia Forum Administrator #8
It is interesting that you have this problem. Looking at the description for those functions on the PHP site ...


htmlspecialchars

Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead.



Judging by the above htmlentities does "more" which is why I use it, however if htmlspecialchars works better for you then by all means use it. Perhaps I should switch too, however it is a bit unclear as to which one is really "better".