nawazmakda
asked on
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/heade r.php on line 13
[19-May-2009 16:01:54] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:05:19] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:08:45] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:12:13] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:15:39] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:19:04] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.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/heade r.php on line 13
[19-May-2009 16:22:32] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html /esh/heade r.php on line 37
Thank you.
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
[19-May-2009 16:01:54] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:01:54] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:05:19] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:05:19] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:05:19] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:08:45] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:08:45] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:08:45] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:12:13] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:12:13] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:12:13] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:15:39] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:15:39] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:15:39] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:19:04] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:19:04] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:19:04] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:22:32] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:22:32] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
[19-May-2009 16:22:32] PHP Notice: Undefined index: HTTP_HOST in /home/<myname>/public_html
Thank you.
<a href="http://<?php echo $_SERVER['HTTP_HOST']; ?>
Hi,
you should use something in between start and end of href tag like:
<a href="http://<?php echo $_SERVER['HTTP_HOST'];?>"> something< /a>
you should use something in between start and end of href tag like:
<a href="http://<?php echo $_SERVER['HTTP_HOST'];?>">
chk if ur register_globals are turned on???
HTH
Manavsi
HTH
Manavsi
HTTP_HOST is not always defined in some cases...
do a var_dump on $_SERVER to check what is getting populated.
do a var_dump on $_SERVER to check what is getting populated.
ASKER
Thank you,, Guys For your suggestions.
But I already use..
; ?>]
In other case
register_globals is turned on here
and at last..
I can't understand the above comment...which says..
"HTTP_HOST is not always defined in some cases...
do a var_dump on $_SERVER to check what is getting populated."
Can u Explain it with some more details..
I think this can be help me to fix my problem.
Thanks a lot once again..
But I already use..
; ?>]
In other case
register_globals is turned on here
and at last..
I can't understand the above comment...which says..
"HTTP_HOST is not always defined in some cases...
do a var_dump on $_SERVER to check what is getting populated."
Can u Explain it with some more details..
I think this can be help me to fix my problem.
Thanks a lot once again..
use the following code and chk if the HTTP_HOST is defined...
HTH
Manavsi
HTH
Manavsi
<?
var_dump($_SERVER);
?>
ASKER
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..
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..
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
Tell me if i'm right or wrong???
Manavsi
ASKER
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?
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?
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
// 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
Hi,
You can use another option:
try:
getenv('HTTP_HOST')
Instead of
$_SERVER['HTTP_HOST']
Regards
You can use another option:
try:
getenv('HTTP_HOST')
Instead of
$_SERVER['HTTP_HOST']
Regards
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sdf
try this:
<a href="http://<?php echo $_SERVER['HTTP_HOST'];?>">