Jump to content



Latest News: (loading..)

- - - - -

Undefined Index Error?


This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#-19   PupStar

PupStar
  • Members
  • 559 posts

Posted 15 March 2012 - 07:54 PM

Hi Guys,

Got an error which I can seem to figure out.

Quote

Notice: Undefined index: HTTP_REFERER in C:\wamp\www\football\includes\functions\whos_online.php on line 112

of which line is:

	  tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, hostname, time_entry, time_last_click, last_page_url, http_referer, user_agent) values ('" . (int)$wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($wo_hostname) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "', '" . tep_db_input($_SERVER['HTTP_REFERER']) . "', '" . tep_db_input($user_agent) . "')");

I have added the index to the table in phpmyadmin but still the error remains but only until I refresh the page and then it goes away.

Any ideas guys?

Thanks

Mark

#-18   MrPhil

MrPhil
  • Members
  • 4,139 posts

Posted 15 March 2012 - 10:07 PM

The $_SERVER superglobal is not guaranteed to contain any particular elements, such as HTTP_REFERER. See http://us.php.net/manual/en/reserved.variables.server.php for details. It's quite possible that your server isn't supplying this element. If this element is definitely used elsewhere in your site, double check your spelling (REFERER, not the proper spelling REFERRER).

#-17   spooks

spooks
  • Members
  • 7,017 posts

Posted 15 March 2012 - 10:38 PM

There can be many cases where you are referring to elements that don't exist, the standard method is to test that it exists before referring to it.

ie:
 (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')

Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.