Reply to Re: error_log : $_COOKIE "Undefined index" "PHP Notice"

Your name:

Reply:


Posted by Michael Fesser on 12/07/07 17:07

..oO(Pseudonyme)

>We thank you for your advise and answer your request. We prey to be as
>clear as possible.
>
>1. error log (130% the weight of the access_log)
>
>PHP Notice: Undefined index: HTTP_REFERER in /home/virtual/site3/fst/
>var/www/html/cpm_cost.php on line 8
>[client 83.155.157.238]

As said earlier, the referrer can be empty, which causes this message.
Before you want to use it (if you want to use it at all, because it's
completely unreliable), check with isset() or empty() if it exists:

if (isset($_SERVER['HTTP_REFERER'])) {
...
}

>PHP Notice: Undefined index: cpm9 in /home/virtual/site3/fst/var/www/
>html/cpm_cost.php on line 45
>[client 83.155.157.238]

Same thing with the cookie value. Obviously it's not set. isset() or
empty() should be used more often.

>PHP Notice: Undefined variable: redirect in /home/virtual/site3/fst/
>var/www/html/cpm_cost.php on line 106

This code:

>line 106 :
>$redirect .='Location:'.$uploadpath;

tries to append a value to $redirect, which is equivalent to

$redirect = $redirect.'Location:'.$uploadpath;

If $redirect doesn't exist yet, you'll get the notice. You could simply
remove the dot to make this an assignment rather than an appending:

$redirect = 'Location:'.$uploadpath;

or

$redirect = "Location: $uploadpath";

Also note that $uploadpath _must_ contain an absolute URL, including the
scheme (http:) and host name. This is required by the HTTP spec.

><?

This should be <?php, since short open tags are unreliable and can be
disabled on the server.

>error_reporting(0);
>include_once("...");
>header("P3P: policyref=\"http://www.gle-mosco.com/adveruser/p3p.xml
>\",CP=\"NON DSP COR CURa PSA PSD OUR BUS NAV STA\"");
>$http_ref= $_SERVER['HTTP_REFERER'];
>$affsite=$_REQUEST['affsite'];
>$banner=$_REQUEST['banner'];

$_REQUEST is usually bad as well, since you don't know where the data is
actually coming from. If you expect a URL parameter, use $_GET.

I didn't go through the rest of the code.

Micha

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация