Received: from virtual1.giganet.nl (tarantula.giganet.nl [212.125.143.1]) by postgresql.org (Postfix) with ESMTP id 01DAE474E42 for ; Tue, 23 Apr 2002 06:33:09 -0400 (EDT) Received: from artemis.cuci.nl (artemis.cuci.nl [212.125.128.9]) by virtual1.giganet.nl (BuGless_3.01) with ESMTP id g3NAXBF13937 for ; Tue, 23 Apr 2002 12:33:11 +0200 Received: from adlsa (adlsa.cm.cuci.nl [10.1.12.174]) by artemis.cuci.nl (BuGless_3.01) with ESMTP id g3NAX9Qw028301 for ; Tue, 23 Apr 2002 12:33:10 +0200 Message-Id: <200204231033.g3NAX9Qw028301@artemis.cuci.nl> Received: from Spooler by adlsa (Mercury/32 v3.30) ID MO000531; 23 Apr 02 12:35:12 +0200 Received: from spooler by arbodienst-limburg.nl (Mercury/32 v3.30); 23 Apr 02 12:27:15 +0200 From: "Jules Alberts" Organization: ARBOdienst Limburg BV To: Date: Tue, 23 Apr 2002 12:27:00 +0200 MIME-Version: 1.0 Subject: Re: global variable problem Reply-To: jules.alberts@arbodienst-limburg.nl In-reply-to: <8298.193.136.62.21.1019553161.squirrel@www.ipatimup.up.pt> References: <200204230643.g3N6hEQw020907@artemis.cuci.nl> X-mailer: Pegasus Mail for Windows (v4.01) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Archive-Number: 200204/82 X-Sequence-Number: 1106 On 23 Apr 2002 at 10:12, Miguel Carvalho wrote: > Jules Alberts wrote: > > besides, my db requires a password so i would have to store it > > somewhere in a variable, which seems a bit of a security risk. > > Where are you going to store the login and database password? > I suggest you to store the login and password in a session variable ( > take a lookt at session_register ). I think that is the best way to do > it. i tried it already with a stored password + user ID. in a global variable, and guess what: they're not visible. but only in the function listing(). in the function start() they are both visible... > > > > i will try this approach anyway, but i still have a few questions > > > > > - when does a script end? at the end of the .PHP file? after a call is > > made to another .PHP file? > > The script ends when the .php file reach it's end( when there is noting > more to parse/ and or execute ). i have a feeling it's more complex than that. a script calls itself, rebuilds HTML code. has the script ended or not? the script that did the call has ended. but since it has called itself, it hasn't. i find these recursion matters a bit vague when it comes to scipts that generate themselves. > > - why is the variable $conn visible in start(), but not in listing()? > > If you want to have access to a global var. inside of a function, you > must say that the global var. is global. Ex: i did that, it doesn't make any difference > > - shouldn't a _P_connect create a persistent connection? > > Possibly it would be a good solution...but there may be some problems, > like: > > doing a roolback in this connection, doest it will roolback all scripts? i don't think that would be a problem, as long as you explicitely do a begin /end transaction. i tried the original script in a more unmodified way (it comes from the latest Dutch issue of C't magazine), but it has the same problem. this made me think that the problem is maybe in some setting in php.ini or httpd.conf. i'm going to do a complete reinstall of apache and php. if the problem persists, i will try to make the script as small as possible while still illustrating the problem. so, maybe until later, and thanks for your reaction. -- Jules Alberts