Solved

Undefined Index when using $_SERVER

Posted on 2003-10-21
7
3,579 Views
Last Modified: 2007-11-27
I am receiving the following error:

Notice: Undefinded index:
I receive this error only on these variables
      $_Server["PHP_AUTH_USER"]
      $_Server["PHP_AUTH_PW"]
      $_Server["AUTH_TYPE"]
      $_Server["HTTP_ACCEPT_CHARSET"]
      $_Server["HTTP_REFERER"]
      $_Server["REMOTE_HOST"]
I have tested all the other Server Variables and they work fine.
       i.e.
          $_Server["REMOTE_PORT"]
          $_Server["SERVER_PORT"]
      and so on...
      these have no problems

I am running Apache_2.0.47-win32-x86-no_ssl Server on Windows NT
and PHP version 4.3.3
I have altered C:\Winnt\php.ini to
     register_globals = On
I have also tried to use HTTP_SERVER_VARS instead of _SERVER and it returns the exact same errors on the same Variables
I have also tried $PHP_AUTH_USER does not work either
I have found several places where people have said they were having the same problem but the solutions did not work for me.
Please help!
0
Comment
Question by:davidtrina
  • 3
  • 3
7 Comments
 
LVL 11

Expert Comment

by:shmert
Comment Utility
Those array indices will only appear in certain cases:

PHP_AUTH_* variables are only in the $_SERVER array if the user has entered HTTP authentication

HTTP_REFERRER is not set if there is no referrer, i.e. if you just type in a URL directly, or the visitor's browser doesn't do referrals for some reason.
0
 
LVL 11

Expert Comment

by:shmert
Comment Utility
To get a better picture of things, I recommend just doing a
print_r($_SERVER);

that willl show you all the contents of the array.
0
 
LVL 1

Author Comment

by:davidtrina
Comment Utility
give me an example script to use PHP_AUTH_* variables I have tried several different ones with the HTTP authentication but perhaps I am doing it wrong
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:davidtrina
Comment Utility
Nevermind I just found a page that says
Also note that this does not work using Microsoft's IIS server and the CGI version of PHP due to a limitation of IIS

I tried to use the Module version with the Apache server but the server would not start when I did this
0
 
LVL 11

Expert Comment

by:shmert
Comment Utility
ah, too bad... I'm not sure how you'd get that information from an IIS webserver.
0
 
LVL 1

Author Comment

by:davidtrina
Comment Utility
Its not an IIS server but it is an apache server running on windows and I configured it to use CGI with PHP because I could not load a module through the http.conf file
It keeps telling me the file php4apache.dll could not be found even though it is definitely in that location dont know why.
0
 
LVL 6

Accepted Solution

by:
aolXFT earned 200 total points
Comment Utility
You can't use HTTP authentication with the PHP CGI. You can only use it when you are using PHP as an apache* modue.

Having that said, I would strongly recommend against using HTTP Authentication with PHP, unless you are doing something very specialised, and consider form based authentication instead.

If you really want to use HTTP Authentication, you'll need to get PHP working as an Apache* Module.



*I could be open to correction on my assumption that this only works with apache, but it certainly doesn't work with CGI, regardless of the server used to execute the CGI Script, since such Authentication is not part of the CGI "Protocol".
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 78
Need some help setting up PDFLib 4 24
Wordpress syntax error 1 27
Button Click 11 22
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now