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

03-15-07, 01:29 AM
|
 |
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
|

03-15-07, 04:19 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 26 Times in 26 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:
UnrealEd
|

03-19-07, 03:01 PM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,121
Thanks: 12
Thanked 94 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:
Or try changing the value in your php.ini file, or try using .htaccess if you don't have access to it.
|

03-19-07, 03:28 PM
|
|
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
|

03-19-07, 11:41 PM
|
 |
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
|

05-20-07, 06:00 AM
|
|
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.
|

08-12-08, 10:23 PM
|
|
New Member
|
|
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Nico
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:
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 =)*
|

03-04-09, 10:48 PM
|
 |
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
|

06-17-10, 03:08 AM
|
|
New Member
|
|
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Not Showing Anymore
Quote:
Originally Posted by Nico
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:
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?
|

06-17-10, 03:14 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 26 Times in 26 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
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|