473,416 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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


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
5 7339
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
..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
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
..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

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: NotGiven | last post by:
I have display error ON and error reporting to E_ALL. I have a form that opens fine. When you submit it, all the fields that have nothing in them, for example an un-selected radio button, throw...
12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
0
by: Marty Meyers | last post by:
TIA for your help! Using PHP 4.3.9 doing some code cleanup on an existing site. I have reduced the problem to: This File is marty.php: <? class Refs { function scriptDir() { echo "Refs are...
5
by: Jim Carlock | last post by:
I've set up the following using an Alias in Apache... Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/" <Directory "C:/Apache/htdocs/common/docs/php"> Options Indexes FollowSymlinks MultiViews...
0
by: jhsedona | last post by:
I try to upgrade site from non-ssl to ssl site, but there are too mcuh thing to do. I decide to use url forwarding to https://www.domain.com for my whole site. When i go to 1st page of site, ...
5
by: Nathan Sokalski | last post by:
I have an ASP.NET application which is giving the following JavaScript error: 'theForm' is undefined However, when I do a View Source one of the <scriptelements is as follows: <script...
6
by: SuperFool | last post by:
This has got to be one of those questions only a serious newbie would come up with.... Basicly: I select all the city names in the table and turn them into a pull down menu (code below) print...
15
by: bill | last post by:
I am trying to write clean code but keep having trouble deciding when to quote an array index and when not to. sometimes when I quote an array index inside of double quotes I get an error about...
4
by: mariaz | last post by:
Hello, I am getting a Notice error on my website that says: Notice: Undefined index: _created_formatted in C:\EasyPHP1-8\www\eP\components\com_jambook\jxtemplate.php(125) : regexp code on line 1 ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.