Re: Re: MySQL Problem

From: Date: Thu, 03 Oct 2002 08:23:42 +0000
Subject: Re: Re: MySQL Problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-118706@lists.php.net to get a copy of this message
I thought someone might mention that, but that is actually correct. The problem is that the variable assigned on the line $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); dissapears and can't be retreived on the line mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] );. For instance, if the first line saves $this->DBLink["TEST"], when CHOOSEDB is called, the command PRINT $this->DBLink["TEST"] will print nothing when the same line right after the variable is saved would produce something like "Resource ID #38". That's the brain twister. Thanks though! ::Lewis "Tom Rogers" <trogers@kwikin.com> wrote in message news:199175859332.20021003182326@kwikin.com... > Hi, > > Thursday, October 3, 2002, 6:01:53 PM, you wrote: > O> You know...maybe I should mention where this code is... > > O> I have my main file which loads using 'require.once' a second file called > O> 'everything.php'. > > O> Inside everything.php is a class called 'mainclass' which is called by the > O> mail file. > > O> This class ('mainclass') loads the MySQL class from the previous post which > O> is stored in yet another file, using require.once. > > O> MainClass then calls the MySQL->CONNECT and MySQL->CHOOSEDB functions. > > O> I know this sounds a bit over the top, but it works...at least it > O> did...until now. I thought I'd mention the circumstances in case that makes > O> a difference, which I suspect it will. > > O> Thanks again! > > O> Lewis > > O> "Orangehairedboy" <me@orangehairedboy.com> wrote in message > O> news:20021003073432.19758.qmail@pb1.pair.com... > >> Hi everyone! I can't figure out why this doesn't work. The call to the > >> CONNECT function works and it connects with no problem, and it does save > O> the > >> Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the > >> Resource ID just saved is gone. $this->DBLink is just empty, and I can't > >> figure out why... > >> > >> Can anyone offer insight on this one? > >> > >> class MySQL > >> { > >> var $DBLink = array(); > >> function CONNECT ( $MyVars , $MyContents ) > >> { > >> $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] : > >> $MyVars[HOST]; > >> $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , > >> $MyVars[USERNAME] , $MyVars[PASSWORD] ); > >> } > >> function CHOOSEDB ( $MyVars , $MyContents ) > >> { > >> mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] ); > >> } > >> } > >> > >> > >> Thanks! > >> > >> > >> Lewis > >> > >> > > Looks like you change the name of the index from NAME to LINK > and it should be $this->DBLink[$MyVars['LINK']] > > -- > regards, > Tom >

« previous php.general (#118706) next »