Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] Getting PHP Notice: Undefined index: HTTP_REFERER in C:\Inetpub\cgi-bin\search5.php o

[SOLVED] Getting PHP Notice: Undefined index: HTTP_REFERER in C:\Inetpub\cgi-bin\search5.php o

Reply
  #1 (permalink)  
Old
mohit's Avatar
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Getting PHP Notice: Undefined index: HTTP_REFERER in C:\Inetpub\cgi-bin\search5.php o

I'm getting the following error PHP Notice: Undefined index: HTTP_REFERER in C:\Inetpub\cgi-bin\search5.php on line 168 on first call..
i'm just trying to get the value of this
$_SERVER['HTTP_REFERER']

any solution for this?

Thanks..
Mohit
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
UnrealEd's Avatar
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 27 Times in 27 Posts
this notive means that the key 'HTTP_REFERER' is not set in the $_SERVER array. Try using this code to see if the key exists, and then start doing stuff with it:
PHP Code:

if(isset($_SERVER['HTTP_REFERER'])){
  
// do stuff

UnrealEd
Reply With Quote
  #3 (permalink)  
Old
Nico's Avatar
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,129
Thanks: 12
Thanked 93 Times in 89 Posts
Your error reporting is not set to its default. Usually E_NOTICEs are not shown.

Try either setting this at the top of your script:
PHP Code:

error_reporting(E_ALL E_NOTICE); 

Or try changing the value in your php.ini file, or try using .htaccess if you don't have access to it.
Reply With Quote
  #4 (permalink)  
Old
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
Umm... While the above posts are OK, they don't answer your question 100%. On the first load of your page (when you open the browser and type the address or jump there form a bookmark/ICQ/newsreader/email) there is no referrer, hence that entry in the $_SERVER array is undefined.

Empty referrer can also be the result of user's browser not sending it (ie, the user has turned off referrers in his browser).
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Reply With Quote
  #5 (permalink)  
Old
mohit's Avatar
Newbie Coder
 
Join Date: Jul 2006
Location: India
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you veru much you all..
My script is not showing that error and i came to learn some new things too..

Thanks again..
We can close this thread here.

Mohit
Reply With Quote
  #6 (permalink)  
Old
New Member
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

Thanks guys for posting this information. I found this forum on Google and problem sorted.
Reply With Quote
  #7 (permalink)  
Old
New Member
 
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Nico View Post
Your error reporting is not set to its default. Usually E_NOTICEs are not shown.

Try either setting this at the top of your script:
PHP Code:

error_reporting(E_ALL E_NOTICE); 

Or try changing the value in your php.ini file, or try using .htaccess if you don't have access to it.
I got the same error message after switching my PHP scripts from Apache to IIS.
Problem solved by adding that code in the master page , thanks!

*hm..yeah I am replying a post that is a year old, but problem solved =)*
Reply With Quote
  #8 (permalink)  
Old
lajevardi's Avatar
New Member
 
Join Date: Jun 2006
Location: Tehran, Iran
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Everyday I'm reading that the people are saying that "this mysterious line of code has solved my problem, thanks!"
As an important note you might want to know that this error_reporting() thing!! is not able to solve any problem. that's just hiding the error echos.

In any "echo" case, such as this, we have to check if the variable is set or not! then we can decide more obviously.

cheers,
Sepehr Lajevardi
Reply With Quote
  #9 (permalink)  
Old
New Member
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Not Showing Anymore

Quote:
Originally Posted by Nico View Post
Your error reporting is not set to its default. Usually E_NOTICEs are not shown.

Try either setting this at the top of your script:
PHP Code:

error_reporting(E_ALL E_NOTICE); 

Or try changing the value in your php.ini file, or try using .htaccess if you don't have access to it.
I added this code and the notice error message is not showing anymore. The thing is it wasn't showing before until I tried installing and uninstalling Zend. And how come it is not showing in my other computer (Linux OS) where I have not installed Zend? Is Zend the culprit of this notice error message?
Reply With Quote
  #10 (permalink)  
Old
UnrealEd's Avatar
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 27 Times in 27 Posts
The culprit of that message is the programmer itself. It means you forgot to declare something before you accessed it. Like using a variable that you haven't declared yet.

The reason why you're not seeing those notices any longer is because, using the code Nico posted, notices are disabled. It's better not to disable them, but to fix them.
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
No error message... stormshadow PHP 3 12-11-06 06:31 PM
Problems getting PHP-Nuke setup correctly TravisT PHP 2 12-17-05 07:54 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
Undefined index: a - help andrewvideo PHP 5 05-17-05 03:33 PM
NOTICE: Undefined index jozin PHP 6 04-29-05 04:19 AM


All times are GMT -5. The time now is 09:38 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.