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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.