Global problem....

From: Date: Wed, 18 Oct 2000 18:25:26 +0000
Subject: Global problem....
Groups: php.install 
Request: Send a blank email to php-install+get-392@lists.php.net to get a copy of this message
Hi, I have a bunch of php3 program's that work just fine. Now I have upgraded to php4 the 'global' declared variables lose there value! It must be some configuration error, but I can't find it... I have compiled php4 with the following options: --with-mysql --with-apxs --enable-calendar Forgot something??? Please help me. Simplefied code: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <? /* Global.php3 */ //-------------------- function Input_Form() //-------------------- { global $KlantID, $SelStrKlant; global $PHP_SELF, $REMOTE_USER, $Action; echo "<P><FORM NAME='Global' ACTION='"; echo $PHP_SELF ."' METHOD='POST'>\n"; echo "<INPUT TYPE=HIDDEN NAME=Action VALUE='$Action'>\n"; echo "<BR>Klantcode : "; if (empty($SelStrKlant)) { echo "<INPUT TYPE=text SIZE=11 MAXLENGTH=11 NAME=IFields[1] "; echo " VALUE='".$KlantID."'"; echo " TABINDEX=1>\n"; } else { echo $SelStrKlant; } ?> <INPUT TYPE=submit NAME=Action VALUE='Check'> <? echo "</FORM>\n"; } // Input_Form() //------------------------- function Check_Fields() //------------------------- { global $KlantID; if (empty($KlantID)) { $Message= "Klantcode: Moet gevuld zijn"; } } // Check_Fields() //-------------------------------------- function Build_SelStrKlant($Klant_naam) //-------------------------------------- { // If, in the main program the $KlantID is empty, then this // function is called to 'build' a selectstring in the // 'global' defines variable '$SelStrKlant' // $SelStrKlant is also defines 'global' in the function Input_Form() // and should be used in stead of the standard input ... global $SelStrKlant; // $SQLstring = "SELECT ID, Naam, Voorletters, Tussenvoegsel, Plaats "; // $SQLstring .= "FROM Klant WHERE Naam LIKE '".$Klant_Naam."%'"; // echo "<BR>".$SQLstring."<BR>\n"; // $SQLresult = mysql_query($SQLstring); $StartString = "<SELECT NAME='IFields[1]'><OPTION VALUE=''>Selecteer\n"; unset($SelStrKlant); $SelStrKlant .= "<OPTION VALUE='KlantOne'>"; $SelStrKlant .= "[XYZ] "; $SelStrKlant .= "Bruin, Piet de"; $SelStrKlant .= "<OPTION VALUE='KlantTwo'>"; $SelStrKlant .= "[ABC] "; $SelStrKlant .= "Black, John"; if (!empty($SelStrKlant)) { $SelStrKlant = $StartString.$SelStrKlant."</SELECT>\n"; } // // remove the '//' in the 'echo' line to see that $SelStrKlant // is actualy not empty // // echo "<BR>[".$SelStrKlant."[<BR>\n"; } // Build_SelStrKlant() // ======== M A I N P R O G R A M ===================== $KlantID = strtoupper($IFields[1]); if ($KlantID == "X0123456789") { $KlantID = "123456789"; // just to do something... } if (empty($KlantID)) { Build_SelStrKlant($KlantID); // <-- this is what it's all about } // Initial HTML code echo "<HTML><HEAD>\n"; echo "<TITLE>Test Global in php(4)</TITLE></HEAD>"; echo "<BODY BGCOLOR=WHITE link=blue vlink=blue alink=red>"; Input_Form(); ?> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> http://www.Aandewiel.nl/ UNIX is not user unfriendly, it is just very specific about who its friends are!

« previous php.install (#392) next »