By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,663 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,663 IT Pros & Developers. It's quick & easy.

error_log : $_COOKIE "Undefined index" "PHP Notice"

P: n/a

Dear All :

Ever had an httpd error_log bigger than the httpd access log ?

We are using Linux-Apache-Fedora-Httpd 2006 configuration.

The PHP lines code that lead too tons of errors are :

$http_ref= $HTTP_REFERER;
$prog = $_COOKIE['cpm'."$j"];
$redirect .='Location:'.$uploadpath;

We believe HTTPD does not understand environement variables.

We had to put that : error_reporting(0); in the top of the file to get
the errors stop to be reported.

An expert said to insert an isset funtion :
http://www.experts-exchange.com/Web_..._21354370.html

But that doeas lead to a success.

From your background and experience, how do you think we can fix up
the code ?

Regards;
Gle Cougloff

Dec 7 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Pseudonyme wrote:
Dear All :

Ever had an httpd error_log bigger than the httpd access log ?

We are using Linux-Apache-Fedora-Httpd 2006 configuration.

The PHP lines code that lead too tons of errors are :

$http_ref= $HTTP_REFERER;
$prog = $_COOKIE['cpm'."$j"];
$redirect .='Location:'.$uploadpath;

We believe HTTPD does not understand environement variables.

We had to put that : error_reporting(0); in the top of the file to get
the errors stop to be reported.

An expert said to insert an isset funtion :
http://www.experts-exchange.com/Web_..._21354370.html

But that doeas lead to a success.

From your background and experience, how do you think we can fix up
the code ?

Regards;
Gle Cougloff

Check to see if $_COOKIE['cpm'."$j"] exists before trying to use it.

Never use a variable (or in this case an array element) unless either
you have set it ourself, or have checked to see if it has been
previously set.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Dec 7 '07 #2

P: n/a
..oO(Pseudonyme)
>We are using Linux-Apache-Fedora-Httpd 2006 configuration.

The PHP lines code that lead too tons of errors are :

$http_ref= $HTTP_REFERER;
Should be

$http_ref = $_SERVER['HTTP_REFERER'];

Also remember that the referrer might be empty or faked.
>$prog = $_COOKIE['cpm'."$j"];
$redirect .='Location:'.$uploadpath;

We believe HTTPD does not understand environement variables.
This has nothing to do with environment variables.
>We had to put that : error_reporting(0); in the top of the file to get
the errors stop to be reported.

An expert said to insert an isset funtion :
http://www.experts-exchange.com/Web_..._21354370.html

But that doeas lead to a success.

From your background and experience, how do you think we can fix up
the code ?
First you should post the _exact_ and _complete_ error messages. Your
message subject says nothing really helpful.

Micha
Dec 7 '07 #3

P: n/a
error log = 130% access_log in terms of weight !
Dear Sirs,

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]
PHP Notice: Undefined index: cpm9 in /home/virtual/site3/fst/var/www/
html/cpm_cost.php on line 45
[client 83.155.157.238]
PHP Notice: Undefined variable: redirect in /home/virtual/site3/fst/
var/www/html/cpm_cost.php on line 106

line 8 : $http_ref= $_SERVER['HTTP_REFERER'];

line 45 :

42. for($j=0; $j <= $i;$j++)
43.{
44.
45. $prog = $_COOKIE['cpm'."$j"];
line 106 :
$redirect .='Location:'.$uploadpath;
2. Extract from cpm_cost. php

<?
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'];
$date = time();
$capping = 300*60;
$i=0;
$cookieok=0;

while(isset($_COOKIE['cpm'."$i"]) )
{
$i++;
}
for($j=0; $j <= $i;$j++)
{

$prog = $_COOKIE['cpm'."$j"];

$array = preg_split('/#/',$prog);
if ($array[0] ==$affsite && $array[1] == $banner && (($array[2] +
$capping) $date) )
{
$cookieok = 1;

}
else if ($array[0] ==$affsite && $array[1] == $banner && (($array[2]
+ $capping) < $date) )
{
$cookieok = 2;
setcookie("cpm".$j,$affsite."#".$banner."#".$date, time()
+24*60*60*365*10);

}
}
if($cookieok == 0)
{
setcookie("cpm".$i,$affsite."#".$banner."#".$date, time()
+24*60*60*365*10);
}
if($cookieok == 2)
{
$cookieok=0;
}
$qryStatus="Select a.status as status, pi.status as prog_status from
Tbl_Affiliate_Program_Status a,Tbl_Creative_Information b,
Tbl_Program_Information pi where a.website_id=$affsite and b.banner_id
= $banner and b.program_id = a.program_id and pi.program_id =
b.program_id";
$rsStatus=select_query($qryStatus);
$site=$affsite;

if($rsStatus['0']['status']=='a' && $rsStatus['0']
['prog_status']=='e' )//only for accepted affiliates
{
$sqlup = "select upload_path,append_type from
Tbl_Creative_Information where banner_id = $banner";
$rsup = select_query($sqlup);

if($rsup['0']['append_type'] != 'h')
{
$uploadpath = $rsup[0]['upload_path'];
}
if(count($uploadpath)!=0)
{
$str = split("#",$uploadpath);
if(count($str) != 0)
{
if(preg_match("/data/", $str[0], $matches)!='')
{
$redirect .='Location:'.$str[0].$affsite;
}
else
{
$redirect .='Location:'.$uploadpath;
}
}
}
if($rsup['0']['append_type'] != 'h') // imagegif($im);
header ($redirect);

$gi = geoip_open("gle-mosco_global/geoIP/GeoIP.dat",
GEOIP_STANDARD);

{
if (!((geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="United
States") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Canada") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Switzerland")
||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Belgium") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="France") ||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="United Kingdom")
||
(geoip_country_name_by_addr($gi, "$REMOTE_ADDR")=="Luxembourg")))
{} else {
if($cookieok == 0)
{
$qryInsert="insert into CPM_TEMP_1H (banner_id,affsite_id)
values($banner,$site)";
update_query($qryInsert);
}
}
}
}
?>
Dec 7 '07 #4

P: n/a
..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
Dec 7 '07 #5

P: n/a

Gonna work on all that.
Again, please receive all my thanks.
Cougloff
Dec 7 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.