On Tue, Feb 25, 2014 at 4:47 PM, Larry Martell <larry.martell@xxxxxxxxx>wrote: > On Tue, Feb 25, 2014 at 4:41 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote: > > > > > > > > On Tue, Feb 25, 2014 at 4:28 PM, Larry Martell <larry.martell@xxxxxxxxx> > > wrote: > >> > >> Is there any way to find out what database I am connected to from a > >> link identifier? > >> > >> I have some code this does this: > >> > >> @ $db = mysql_pconnect($dbserver, $dbuser, $dbpass); > >> @ mysql_select_db($dbname, $db); > >> > >> I know at the time this is executed $dbname is what I want it to be. > >> But later on when I pull data using $db, I get data from a different > >> database. If I try to echo $db at the time of the query I get > >> "Resource id #5". Can I get the database name from $db? > >> > >> -- > >> PHP General Mailing List (http://www.php.net/) > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> > > > > You won't be able to, you will need to execute a query on that DB > connection > > handler to check the DB name currently used: > > > > SELECT DATABASE() as DB_NAME > > Thanks! Indeed I am not 'using' the db that $dbname is set to when I > execute the mysql_select_db command. Now I just have to figure out why > that is. > Are you making a call to mysql_select_db besides the above during your code execution (even on a different DB handler)? If yes, then that would be the issue since.