Why this Undefined index: HTTP_HOST

Why I am getting this warning?

So plz tell me how can I fix this problem.?


[19-May-2009 16:01:54] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:01:54] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:01:54] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:05:19] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:05:19] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:05:19] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:08:45] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:08:45] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:08:45] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:12:13] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:12:13] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:12:13] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:15:39] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:15:39] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:15:39] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:19:04] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:19:04] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:19:04] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37
[19-May-2009 16:22:32] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/home.php on line 14
[19-May-2009 16:22:32] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 13
[19-May-2009 16:22:32] PHP Notice:  Undefined index:  HTTP_HOST in /home/<myname>/public_html/esh/header.php on line 37

Thank you.
<a href="http://<?php echo $_SERVER['HTTP_HOST']; ?>

Open in new window

nawazmakdaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shobinsunCommented:
Hi,

try this:

<a href="http://<?php echo $_SERVER['HTTP_HOST'];?>">
0
shobinsunCommented:
Hi,

you should use something in between start and end of href tag like:

<a href="http://<?php echo $_SERVER['HTTP_HOST'];?>">something</a>
0
manavsiCommented:
chk if ur register_globals are turned on???

HTH
Manavsi
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

BrianMMCommented:
HTTP_HOST is not always defined in some cases...

do a var_dump on $_SERVER to check what is getting populated.
0
manavsiCommented:
use the following code and chk if the HTTP_HOST is defined...

HTH
Manavsi
<?
var_dump($_SERVER);
 
?>

Open in new window

0
nawazmakdaAuthor Commented:
hi Manavsi,
Thaks again..! for replying me

doing  var_dump on $_SERVER It gives output that  HTTP_HOST is already defined and also HTTP_REFERER is set too.


anyway..
From some where I found to do that,

Those messages 'PHP Notice' are not error messages as such.

Edit php.ini file and find this line

error_reporting = E_ALL & ~E_NOTICE

This will turn off notices but still show any errors.

Hope this helps,



Thanks for you support Guys..
0
manavsiCommented:
hey i dont get it... though its still a notice.. ur purpose of getting the value from the HTTP_HOST will not work right...???

Tell me if i'm right or wrong???

Manavsi
0
nawazmakdaAuthor Commented:
heyyyyy Manavsi

no my purpose was that why I am getting those type of error messages..?
what is the reason behind it?

how do I Solve this problem and avoid to get those error messages?
0
shobinsunCommented:
Hi,

// how do I Solve this problem and avoid to get those error messages?

Ans: you need to set your php.ini file to not display notices. displaying warnings and errors, but not notices is the most typical setup and what most people code for.

error_reporting  =  E_ALL & ~E_NOTICE

also, if you still run into problems, you may have to turn on register_globals. it's not as secure as having it off, but again, most servers are setup this way:

register_globals On

once you have made the changes in your php.ini file, restart your web server


Regards
0
shobinsunCommented:
Hi,

You can use another option:

try:

getenv('HTTP_HOST')

Instead of

$_SERVER['HTTP_HOST']


Regards
0
BrianMMCommented:
it also could be due to Apache version... if you are using apache there is an intermittant bug in older versionf of Apache that cause it not to be set but as above post should get it from that... getenv() that is if $_SERVER does not work...
0
nawazmakdaAuthor Commented:
Thank you,, Friends For your support.

I am not receiving this notice due to setting in php.ini file

"error_reporting  =  E_ALL & ~E_NOTICE"



Any Way.........

Thanking  you All Of Guys ...

Have a Nice Day
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nawazmakdaAuthor Commented:
sdf
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.