Page 1 of 1

Moved to NT server get Index/Variable Undefined error!

Posted: Fri Aug 22, 2003 1:14 am
by rebyphp
A script working perfectly in Linux server. After moving the script from a NT server, I got a lot Index and Variable Undefined. Please assist.

The setting for NT server: PHP 4.1.1 / register_globals = OFF. /register_argc_argv = Off

The Linux server: PHP 4.3.0 / register_globals = ON.

The purpose of the script - check required info, some text field if empty just remove from the final message.

Code: Select all

<?php
$Title = $_REQUEST ['Title'];  
$First_name = $_REQUEST ['First_name']; 
$Last_name = $_REQUEST ['Last_name'];
$Organisation = $_REQUEST ['Organisation']; 
$Phone = $_REQUEST ['Phone']; 
$Phone_alt = $_REQUEST ['Phone_alt']; 
$Fax = $_REQUEST ['Fax']; 
$District = $_REQUEST ['District']; 
$Address = $_REQUEST ['Address']; 
$Submit_by = $_REQUEST ['Submit_by']; 
$Books = $_REQUEST ['Books']; 
$Books_description = $_REQUEST ['Books_description']; 
$Books_Expiry_Day = $_REQUEST ['Books_Expiry_Day']; 
$Books_Expiry_Month = $_REQUEST ['Books_Expiry_Month']; 
$Books_Expiry_Year = $_REQUEST ['Books_Expiry_Year']; 
$Building_material = $_REQUEST ['Building_material']; 
$Building_material_description = $_REQUEST ['Building_material_description']; 
$Building_Expiry_Day = $_REQUEST ['Building_Expiry_Day']; 
$Building_Expiry_Month = $_REQUEST ['Building_Expiry_Month']; 
$Building_Expiry_Year = $_REQUEST ['Building_Expiry_Year']; 
$Clothing = $_REQUEST ['Clothing']; 
$Clothing_description = $_REQUEST ['Clothing_description']; 
$Clothing_Expiry_Day = $_REQUEST ['Clothing_Expiry_Day']; 
$Clothing_Expiry_Month = $_REQUEST ['Clothing_Expiry_Month']; 
$Clothing_Expiry_Year = $_REQUEST ['Clothing_Expiry_Year']; 
$Computers = $_REQUEST ['Computers']; 
$Computers_description = $_REQUEST ['Computers_description']; 
$Computers_Expiry_Day = $_REQUEST ['Computers_Expiry_Day']; 
$Computers_Expiry_Month = $_REQUEST ['Computers_Expiry_Month']; 
$Computers_Expiry_Year = $_REQUEST ['Computers_Expiry_Year']; 
$Electrical = $_REQUEST ['Electrical']; 
$Electrical_description = $_REQUEST ['Electrical_description']; 
$Electrical_Expiry_Day = $_REQUEST ['Electrical_Expiry_Day']; 
$Electrical_Expiry_Month = $_REQUEST ['Electrical_Expiry_Month']; 
$Electrical_Expiry_Year = $_REQUEST ['Electrical_Expiry_Year']; 
$Food = $_REQUEST ['Food']; 
$Food_description = $_REQUEST ['Food_description']; 
$Food_Expiry_Day = $_REQUEST ['Food_Expiry_Day']; 
$Food_Expiry_Month = $_REQUEST ['Food_Expiry_Month']; 
$Food_Expiry_Year = $_REQUEST ['Food_Expiry_Year']; 
$Furniture = $_REQUEST ['Furniture']; 
$Furniture_description = $_REQUEST ['Furniture_description']; 
$Furniture_Expiry_Day = $_REQUEST ['Furniture_Expiry_Day']; 
$Furniture_Expiry_Month = $_REQUEST ['Furniture_Expiry_Month']; 
$Furniture_Expiry_Year = $_REQUEST ['Furniture_Expiry_Year']; 
$Household = $_REQUEST ['Household']; 
$Household_description = $_REQUEST ['Household_description']; 
$Household_Expiry_Day = $_REQUEST ['Household_Expiry_Day']; 
$Household_Expiry_Month = $_REQUEST ['Household_Expiry_Month']; 
$Household_Expiry_Year = $_REQUEST ['Household_Expiry_Year']; 
$Medical = $_REQUEST ['Medical']; 
$Medical_description = $_REQUEST ['Medical_description']; 
$Medical_Expiry_Day = $_REQUEST ['Medical_Expiry_Day']; 
$Medical_Expiry_Month = $_REQUEST ['Medical_Expiry_Month']; 
$Medical_Expiry_Year = $_REQUEST ['Medical_Expiry_Year']; 
$Stationery = $_REQUEST ['Stationery']; 
$Stationery_description = $_REQUEST ['Stationery_description']; 
$Stationery_Expiry_Day = $_REQUEST ['Stationery_Expiry_Day']; 
$Stationery_Expiry_Month = $_REQUEST ['Stationery_Expiry_Month']; 
$Stationery_Expiry_Year = $_REQUEST ['Stationery_Expiry_Year']; 
$Toys = $_REQUEST ['Toys']; 
$Toys_description = $_REQUEST ['Toys_description']; 
$Toys_Expiry_Day = $_REQUEST ['Toys_Expiry_Day']; 
$Toys_Expiry_Month = $_REQUEST ['Toys_Expiry_Month']; 
$Toys_Expiry_Year = $_REQUEST ['Toys_Expiry_Year']; 
$Miscellaneous = $_REQUEST ['Miscellaneous']; 
$Misc_description = $_REQUEST ['Misc_description']; 
$Misc_Expiry_Day = $_REQUEST ['Misc_Expiry_Day']; 
$Misc_Expiry_Month = $_REQUEST ['Misc_Expiry_Month']; 
$Misc_Expiry_Year = $_REQUEST ['Misc_Expiry_Year']; 
$Transportation = $_REQUEST ['Transportation']; 
$Comments = $_REQUEST ['Comments'];
$INCLUDE = $_REQUEST ['INCLUDE']; 
//some common usage.
$b = "===============================\r";
$r = "\r";
$t = "\t";
//Label of values:
$L_Title = "Title: ";  
$L_First_name = "First_name: "; 
$L_Last_name = "Last_name: "; 
$L_Organisation = "Organisation: "; 
$L_Phone = "Phone: "; 
$L_Phone_alt = "Phone_alt: "; 
$L_Fax = "Fax: "; 
$L_District = "District: "; 
$L_Address = "Address: "; 
$L_Submit_by = "Email: "; 
$L_Books = "Books: "; 
$L_Books_description = "Books_description: "; 
$L_Books_Expiry_Day = "Books_Expiry_Day: "; 
$L_Books_Expiry_Month = "Books_Expiry_Month: "; 
$L_Books_Expiry_Year = "Books_Expiry_Year: "; 
$L_Building_material = "Building_material: "; 
$L_Building_material_description = "Building_material_description: "; 
$L_Building_Expiry_Day = "Building_Expiry_Day: "; 
$L_Building_Expiry_Month = "Building_Expiry_Month: "; 
$L_Building_Expiry_Year = "Building_Expiry_Year: "; 
$L_Clothing = "Clothing: "; 
$L_Clothing_description = "Clothing_description: "; 
$L_Clothing_Expiry_Day = "Clothing_Expiry_Day: "; 
$L_Clothing_Expiry_Month = "Clothing_Expiry_Month: "; 
$L_Clothing_Expiry_Year = "Clothing_Expiry_Year: "; 
$L_Computers = "Computers: "; 
$L_Computers_description = "Computers_description: "; 
$L_Computers_Expiry_Day = "Computers_Expiry_Day: "; 
$L_Computers_Expiry_Month = "Computers_Expiry_Month: "; 
$L_Computers_Expiry_Year = "Computers_Expiry_Year: "; 
$L_Electrical = "Electrical: "; 
$L_Electrical_description = "Electrical_description: "; 
$L_Electrical_Expiry_Day = "Electrical_Expiry_Day: "; 
$L_Electrical_Expiry_Month = "Electrical_Expiry_Month: "; 
$L_Electrical_Expiry_Year = "Electrical_Expiry_Year: "; 
$L_Food = "Food: "; 
$L_Food_description = "Food_description: "; 
$L_Food_Expiry_Day = "Food_Expiry_Day: "; 
$L_Food_Expiry_Month = "Food_Expiry_Month: "; 
$L_Food_Expiry_Year = "Food_Expiry_Year: "; 
$L_Furniture = "Furniture: "; 
$L_Furniture_description = "Furniture_description: "; 
$L_Furniture_Expiry_Day = "Furniture_Expiry_Day: "; 
$L_Furniture_Expiry_Month = "Furniture_Expiry_Month: "; 
$L_Furniture_Expiry_Year = "Furniture_Expiry_Year: "; 
$L_Household = "Household: "; 
$L_Household_description = "Household_description: "; 
$L_Household_Expiry_Day = "Household_Expiry_Day: "; 
$L_Household_Expiry_Month = "Household_Expiry_Month: "; 
$L_Household_Expiry_Year = "Household_Expiry_Year: "; 
$L_Medical = "Medical: "; 
$L_Medical_description = "Medical_description: "; 
$L_Medical_Expiry_Day = "Medical_Expiry_Day: "; 
$L_Medical_Expiry_Month = "Medical_Expiry_Month: "; 
$L_Medical_Expiry_Year = "Medical_Expiry_Year: "; 
$L_Stationery = "Stationery: "; 
$L_Stationery_description = "Stationery_description: "; 
$L_Stationery_Expiry_Day = "Stationery_Expiry_Day: "; 
$L_Stationery_Expiry_Month = "Stationery_Expiry_Month: "; 
$L_Stationery_Expiry_Year = "Stationery_Expiry_Year: "; 
$L_Toys = "Toys: "; 
$L_Toys_description = "Toys_description: "; 
$L_Toys_Expiry_Day = "Toys_Expiry_Day: "; 
$L_Toys_Expiry_Month = "Toys_Expiry_Month: "; 
$L_Toys_Expiry_Year = "Toys_Expiry_Year: "; 
$L_Miscellaneous = "Miscellaneous: "; 
$L_Misc_description = "Misc_description: "; 
$L_Misc_Expiry_Day = "Misc_Expiry_Day: "; 
$L_Misc_Expiry_Month = "Misc_Expiry_Month: "; 
$L_Misc_Expiry_Year = "Misc_Expiry_Year: "; 
$L_Transportation = "Transportation: "; 
$L_Comments = "Comments: ";
// 
//optional content
//
if (! empty($Organisation)){
	$option_content = $L_Organisation. $Organisation. $r;
 	}
if (! empty($Phone_alt)){
 	$option_content .= $L_Phone_alt. $Phone_alt. $r;
 	}
if (! empty($Fax)){
 	$option_content .= $L_Fax. $Fax. $r;
 	}
//
if (! empty($Address)){
 	$option_content1 = $L_Address. $r. $Address. $r;
 	}
if (! empty($Submit_by)){
 	$option_content1 .= $L_Submit_by. $Submit_by. $r;
 	}
//
//The required content
//
if (!$Title == "None"){
 $req_content = $L_Title. $Title. $r;
 $Title = $head;
}
 $req_content .= $L_First_name. $First_name. $r;
 $req_content .= $L_Last_name. $Last_name. $r;
 $req_content .= $L_Phone. $Phone. $r;
// 
 $req_content1 .= $L_District. $District. $r; 
//
//the donating goods
//
 if (isset($Books))
 {
 $content .=  $b;
 $content .=  $L_Books_description. $r. $Books_description. $r;
 $content .= "Books_Expiry_Date: $Books_Expiry_Day / $Books_Expiry_Month / $Books_Expiry_Year $r";
 } 
 if (isset($Building_material))
 {
 $content .= $b;
 $content .= $L_Building_material_description. $r. $Building_material_description. $r; 
 $content .= "Building material Expiry Date: $Building_Expiry_Day / $Building_Expiry_Month / $Building_Expiry_Year $r";
 }; 
 if (isset($Clothing))
 {
 $content .=  $b;
 $content .=  $L_Clothing_description. $r. $Clothing_description. $r;
 $content .= "Clothing_Expiry_Date: $Clothing_Expiry_Day / $Clothing_Expiry_Month / $Clothing_Expiry_Year $r";
 } 
 if (isset($Computers))
 {
 $content .=  $b;
 $content .=  $L_Computers_description. $r. $Computers_description. $r;
 $content .= "Computers_Expiry_Date: $Computers_Expiry_Day / $Computers_Expiry_Month / $Computers_Expiry_Year $r";
 } 
 if (isset($Electrical))
 {
 $content .=  $b;
 $content .=  $L_Electrical_description. $r. $Electrical_description. $r;
 $content .= "Electrical_Expiry_Date: $Electrical_Expiry_Day / $Electrical_Expiry_Month / $Electrical_Expiry_Year $r";
 } 
 if (isset($Food))
 {
 $content .=  $b;
 $content .=  $L_Food_description. $r. $Food_description. $r;
 $content .= "Food_Expiry_Date: $Food_Expiry_Day / $Food_Expiry_Month / $Food_Expiry_Year $r";
 } 
 if (isset($Furniture))
 {
 $content .=  $b;
 $content .=  $L_Furniture_description. $r. $Furniture_description. $r;
 $content .= "Furniture_Expiry_Date: $Furniture_Expiry_Day / $Furniture_Expiry_Month / $Furniture_Expiry_Year $r";
 } 
 if (isset($Household))
 {
 $content .=  $b;
 $content .=  $L_Household_description. $r. $Household_description. $r;
 $content .= "Household_Expiry_Date: $Household_Expiry_Day / $Household_Expiry_Month / $Household_Expiry_Year $r";
 } 
 if (isset($Medical))
 {
 $content .=  $b;
 $content .=  $L_Medical_description. $r. $Medical_description. $r;
 $content .= "Medical_Expiry_Date: $Medical_Expiry_Day / $Medical_Expiry_Month / $Medical_Expiry_Year $r";
 } 
 if (isset($Stationery))
 {
 $content .=  $b;
 $content .=  $L_Stationery_description. $r. $Stationery_description. $r;
 $content .= "Stationery_Expiry_Date: $Stationery_Expiry_Day / $Stationery_Expiry_Month / $Stationery_Expiry_Year $r";
 } 
 if (isset($Toys))
 {
 $content .=  $b;
 $content .=  $L_Toys_description. $r. $Toys_description. $r;
 $content .= "Toys_Expiry_Date: $Toys_Expiry_Day / $Toys_Expiry_Month / $Toys_Expiry_Year $r";
 } 
 if (isset($Miscellaneous))
 {
 $content .=  $b;
 $content .=  $L_Misc_description. $r. $Misc_description. $r; 
 $content .= "Misc_Expiry_Date: $Misc_Expiry_Day / $Misc_Expiry_Month / $Misc_Expiry_Year $r";
 } 
//transportation value here....
$content .=  $b;
If ($Transportation = "YES")
{
$content .= $L_Transportation. $Transportation. $r;
}
elseif ($Transportation = "NO")
{
$content .= $L_Transportation. $Transportation. $r;
}
if (isset ($Comments))
{
$content .=  $b;
$content .=  $L_Comments. $r. $Comments. $r; 
}
//========================
//to GlobalHand(GH), PublicList(Public) and ReplytoSender(Reply)....
//---------
$messageGH = "This information is submitted to Global Hand on ". date("Y.m.d > H:i") . $r. $b;
$messageGH .= $req_content . $option_content . $req_content1 . $option_content1 . $content . $b;
//---------
$messagePublic = "This information is submitted to Public List on ". date("Y.m.d > H:i") . $r. $b;
If (isset($INCLUDE))
{
$messagePublic = $req_content . $option_content . $option_content1;
}
$messagePublic .= $req_content1 . $r. $b;
$messagePublic .= $content . $b;
//---------
$messageReply = "Dear $head $First_name $Last_name : $r $r";
$messageReply .= "This is some default text which goes at the top of the emails... $r $r";
$messageReply .= $content . $b . $r;
$messageReply .= "Thanks for using Global Hand!.... $r Global Hand Team";
//
//Mail values:
    $toGH = "some@com.net"; 
    $toPublic = "some@com.net";
    $subjectGH = "(testing stage) : donating goods information";
    $subjectPublic = "(testing stage) : donating goods public list information";
    $subjectReply = "Thanks for using!.... (testing stage)";
	$extra = "From: $Submit_by\r \n" ;
	$fromGH = "From: some@com.net";
//	
//to the list	
//
if ( empty($First_name) || empty($Last_name) || empty($Phone) || empty($Submit_by) || empty($District)){
header("Location: hkoops.htm");}
else
{
	if (mail($toGH, $subjectGH, $messageGH, $extra) && mail($toPublic, $subjectPublic, $messagePublic, $extra) && mail($Submit_by, $subjectReply, $messageReply, $fromGH))
    	{
			header("Location: hkthankyou.htm");
   		}
     	else
    	{
    		echo "The mail server has experienced problems, Please try again later.";
    	}
}	
?>
error messages only from NT server:

Code: Select all

PHP Warning: Undefined index: Building_material in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
17 PHP Warning: Undefined index: Computers in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
27 PHP Warning: Undefined index: Electrical in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
32 PHP Warning: Undefined index: Food in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
37 PHP Warning: Undefined index: Furniture in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
42 PHP Warning: Undefined index: Household in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
47 PHP Warning: Undefined index: Medical in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
52 PHP Warning: Undefined index: Stationery in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
57 PHP Warning: Undefined index: Toys in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
62 PHP Warning: Undefined index: Miscellaneous in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
67 PHP Warning: Undefined variable: req_content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
183 PHP Warning: Undefined variable: req_content1 in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
187 PHP Warning: Undefined variable: content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
223 PHP Warning: Undefined variable: head in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
322

Code: Select all

PHP Warning: Undefined variable: option_content1 in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
174 PHP Warning: Undefined variable: req_content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
183 PHP Warning: Undefined variable: req_content1 in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
187 PHP Warning: Undefined variable: content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
223 PHP Warning: Undefined variable: option_content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
312 PHP Warning: Undefined variable: option_content in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
317 PHP Warning: Undefined variable: head in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
322 PHP Warning: Cannot add header information - headers already sent in
E:\www\tld\globalhand\public_html\donategoods2\hkdonateprocess.php on line
Thank very much....

Posted: Fri Aug 22, 2003 2:53 am
by jamiejackson
Had very similar problems to this and got some great help on this forum. Its all to do with levels of error reporting, your NT box is reporting everything, warnings and all.

Anyway, I cannot take credit for this wizdom. Mr McGruff helped me, you can read his sage advice here

Hope it helps.

Posted: Fri Aug 22, 2003 5:48 am
by volka
decreasing the error reporting/log level only cures the symptoms, not the cause.
As stated in McGruff's answers there is a way to test wether a variable (in this case a http-request parameter) is set or not.

e.g.
$Building_material = $_REQUEST ['Building_material'];
if there is no parameter Building_material sent with the request php will create a warning and $Building_material is set to NULL.
you might set default values with a structure like

Code: Select all

$Building_material = isset($_REQUEST ['Building_material']) ? $_REQUEST ['Building_material'] : 'default value';
but that's not always feasable...