Jump to content

Unsure about error


Topshed

Recommended Posts

Hi,

 

I am trying to get a "contact me script" to work but an error in the config file is giving me problems

but it is something not to be edited

 

/// edit end
$urlh = getenv(HTTP_HOST);
$siteurl = "http://$urlh";

?>

 

The error it get is

Use of undefined constant HTTP_HOST - assumed 'HTTP_HOST' in \contact\config.php on line 7

 

I googled the problem and as far as I can tell, it may be because I am using a windows host rather than unix

 

any help / suggestions  please

 

Thanks

topshed

Link to comment
https://forums.phpfreaks.com/topic/91672-unsure-about-error/
Share on other sites

It is simply due to poor coding. The getenv() function expects a string.

 

Change...

 

$urlh = getenv(HTTP_HOST);

 

to....

 

$urlh = getenv('HTTP_HOST');

 

I would probably consider using another contact me script, this is a simple mistake and one that should not be made by any decent developer.

Link to comment
https://forums.phpfreaks.com/topic/91672-unsure-about-error/#findComment-469502
Share on other sites

Well, the error was in fact corrected by the PHP runtime, turning HTTP_HOST into 'HTTP_HOST', so I suspect the problem IS actually related to your operating system. Environmental variables are NOT to be trusted between windows and linux, hence HTTP_HOST might exist on 1 and not the other. Instead I would rely on the $_SERVER variables as MOST of these are populated with the information you want.

Link to comment
https://forums.phpfreaks.com/topic/91672-unsure-about-error/#findComment-469514
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.