Post by werepair » Mon Oct 31, 2011 8:43 pm

getting 2 error messages in my error log.

2011-10-31 10:26:31 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxxx/public_html/index.php on line 179
2011-10-31 10:26:31 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxxx/public_html/system/library/currency.php on line 45

any idea ?

line 44 currency.php

Code: Select all

if ((!isset($this->request->cookie['currency'])) || ($this->request->cookie['currency'] != $currency)) {
	  		setcookie('currency', $currency, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
    	}
  	}

line 178 index.php

Code: Select all

if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) {	  
	setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']);
}
Best Regards

User avatar
Active Member

Posts

Joined
Sat May 28, 2011 2:54 pm
Location - United Kingdom

Post by wernerrenrew » Tue Nov 01, 2011 1:36 pm

Hi,

Change HTTP_HOST to SERVER_NAME to prevent problems with client not setting HTTP_HOST

Or just ignore those clients probly bad spiders :laugh:

User avatar
Active Member

Posts

Joined
Thu Oct 27, 2011 9:48 pm
Location - Netherlands

Post by uksitebuilder » Tue Nov 01, 2011 3:40 pm

Be careful using SERVER_NAME, if this is not correctly set-up in your server config then it wont work

Likewise if you run multi stores then you shouldn't use SERVER_NAME

If HTTP_HOST is missing it either means the (a) the client is using a very old browser, (b) the bot doesn't send it or (c) the site is being accessed by it's IP Address rather than the domain name

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by wernerrenrew » Tue Nov 01, 2011 4:38 pm

uksitebuilder wrote:Be careful using SERVER_NAME, if this is not correctly set-up in your server config then it wont work

Likewise if you run multi stores then you shouldn't use SERVER_NAME

If HTTP_HOST is missing it either means the (a) the client is using a very old browser, (b) the bot doesn't send it or (c) the site is being accessed by it's IP Address rather than the domain name
Why would a multi store setup be a problem it's the cookie domain set most likely to the www. subdomain in case of multi domain setup in my opinion SERVER_NAME would be the better choice it could be set by the server (ofcourse the best solution in case of multi setup is define the cookie domein and set it to .my-domain.com), also it's very unlikely that this is not configured correctly but if that's the case it's time for a support ticket better yet find another host or someone to configure your dedicated server correctly :D

Advice just ignore those errors it's not your customers generating them so why change any core files.

User avatar
Active Member

Posts

Joined
Thu Oct 27, 2011 9:48 pm
Location - Netherlands

Post by werepair » Wed Nov 02, 2011 3:53 am

uksitebuilder wrote:Be careful using SERVER_NAME, if this is not correctly set-up in your server config then it wont work

Likewise if you run multi stores then you shouldn't use SERVER_NAME

If HTTP_HOST is missing it either means the (a) the client is using a very old browser, (b) the bot doesn't send it or (c) the site is being accessed by it's IP Address rather than the domain name
Thanks for the input
not sure whats the problem is to be honest, the site is a mirror image of another site with a different logo and name, all the products are the same yet no errors on the other site.

Best Regards

User avatar
Active Member

Posts

Joined
Sat May 28, 2011 2:54 pm
Location - United Kingdom

Post by Qphoria » Tue Aug 21, 2012 10:34 pm

I've seen recommendations to use getenv('HTTP_HOST') instead of $_SERVER['HTTP_HOST']. This issue just started recently on my webhost too.. so I'll keep you updated

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dave310 » Wed Aug 22, 2012 5:46 am

I am facing the same error problem. Anyone found any solution? we are not on multishop. so whats with "change to server name???" Can someone guide please.

New member

Posts

Joined
Fri Mar 23, 2012 5:47 pm

Post by Qphoria » Wed Aug 22, 2012 11:43 pm

dave310 wrote:I am facing the same error problem. Anyone found any solution? we are not on multishop. so whats with "change to server name???" Can someone guide please.
Based on my post above.. you can change your index.php file like this.

1. EDIT: index.php

2. FIND THIS BLOCK:

Code: Select all

// Store
if (isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} 
3. REPLACE WITH THIS BLOCK:

Code: Select all

// Store
$http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : getenv('HTTP_HOST');

if (isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $http_host) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $http_host) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
}
 

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by moneycarlo » Fri Sep 07, 2012 9:46 am

I'm still seeing this error in my log after i've changed my index.php.
Other Ideas?

Active Member

Posts

Joined
Wed Sep 28, 2011 3:40 am

Post by eddie_d » Tue Oct 16, 2012 5:51 pm

Qphoria being as you are the opencart GOD and you have/had this problem any news on error I have exhausted all suggested solutions I found on the web, even scrapped my site and done fresh install with 1.5.4.1 thinking that will fix it. I don't think it is causing major problems but i hate seeing errors in the log.

Regards

Eddie

Our online shop using OpenCart http://www.enscomputers.co.uk


New member

Posts

Joined
Fri Feb 03, 2012 4:28 am
Location - Somerset UK

Post by eddie_d » Tue Oct 16, 2012 6:01 pm

here are my errors

2012-10-16 8:26:13 - PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/xxxxx/public_html/index.php:49) in /home/xxxx/public_html/system/library/session.php on line 11
2012-10-16 8:26:13 - PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/xxxxx/public_html/index.php:49) in /home/xxxxxx/public_html/system/library/session.php on line 11
2012-10-16 8:26:13 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxx/public_html/index.php on line 177
2012-10-16 8:26:13 - PHP Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxx/public_html/index.php:49) in /home/xxxxx/public_html/index.php on line 177
2012-10-16 8:26:13 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxx/public_html/system/library/currency.php on line 45
2012-10-16 8:26:13 - PHP Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxx/public_html/index.php:49) in /home/xxxx/public_html/system/library/currency.php on line 45

regards

eddie

Our online shop using OpenCart http://www.enscomputers.co.uk


New member

Posts

Joined
Fri Feb 03, 2012 4:28 am
Location - Somerset UK

Post by bobwhite » Fri Oct 26, 2012 10:30 pm

I am getting similar errors:
2012-10-19 22:31:32 - PHP Notice: Undefined index: HTTP_HOST in /public_html/index.php on line 179
2012-10-19 22:31:32 - PHP Warning: Cannot modify header information - headers already sent by (output started at /public_html/index.php:49) in /public_html/index.php on line 179
2012-10-19 22:31:32 - PHP Notice: Undefined index: HTTP_HOST in /public_html/system/library/currency.php on line 45
2012-10-19 22:31:32 - PHP Warning: Cannot modify header information - headers already sent by (output started at /public_html/index.php:49) in /public_html/system/library/currency.php on line 45

Thanks,

User avatar
New member

Posts

Joined
Thu Jan 26, 2012 8:20 am

Post by stringtokenizer » Wed Jan 23, 2013 3:01 pm

I am having a same problem.

2013-01-22 14:22:31 - PHP Notice: Undefined index: HTTP_HOST in /home/public_html/system/library/currency.php on line 45

Any idea ?


Posts

Joined
Fri Oct 08, 2010 12:48 pm

Post by HorseMagic » Sat Mar 09, 2013 5:31 am

We have same problem and we have the above code from Qphoria in index file already.

2013-03-08 3:16:29 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxxx/public_html/index.php on line 179
2013-03-08 3:16:29 - PHP Notice: Undefined index: HTTP_HOST in /home/xxxxxxx/public_html/system/library/currency.php on line 45

I am guessing by what is said in these posts it is not an error to worry about?

Anita


User avatar
New member

Posts

Joined
Sat Jan 21, 2012 1:55 pm
Location - Australia
Who is online

Users browsing this forum: No registered users and 75 guests