Pear DB - Connecting twice from same script

From: Date: Tue, 08 Apr 2003 13:27:22 +0000
Subject: Pear DB - Connecting twice from same script
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4707@lists.php.net to get a copy of this message
I am having difficulty connecting to a database twice within the same script using pear DB. The error message reads: Fatal error: Call to undefined function: query() in /home/rob/public_html/sirius/includes/library.php on line 34 It works on the first function connect but not the second time around. Is there some reason why I can't do it like this? Any help is appreciated! /Rob library.php looks like this: <?php function drawSiteNavPanel(){ require_once('includes/connViewRCSI.php'); require_once('DB.php'); $db=DB::connect("$dbsrvr://$dbuser:$dbpass@$dbhost/$dbname"); $sqlNP="SELECT * FROM sitenavcats WHERE sncLive = '1'"; $qryResultNP=$db->query($sqlNP); if(DB::isError($qryResultNP=$db->query($sqlNP))) echo DB::errorMessage($qryResultNP); else while($qryColNP=$qryResultNP->fetchRow()){ echo "<strong>$qryColNP[1]</strong><br />\n"; $sqlNC="SELECT * FROM sitenavlinks WHERE snlSNC='$qryColNP[0]' AND snlLive = '1' ORDER BY snlDispName"; $qryResultNC=$db->query($sqlNC); if(DB::isError($qryResultNC=$db->query($sqlNC))) echo DB::errorMessage($qryResultNC); else{ while($qryColNC=$qryResultNC->fetchRow()) echo "<a href=\"$qryColNC[2]\">$qryColNC[1]</a><br />\n"; $qryResultNC->free(); echo "<hr />\n"; } } $qryResultNP->free(); $db->disconnect(); } function drawAdminNavPanel(){ require_once('includes/connViewRCSI.php'); require_once('DB.php'); $db=DB::connect("$dbsrvr://$dbuser:$dbpass@$dbhost/$dbname"); $sqlNP="SELECT * FROM adminnavcats WHERE ancLive = '1'"; $qryResultNP=$db->query($sqlNP); if(DB::isError($qryResultNP=$db->query($sqlNP))) echo DB::errorMessage($qryResultNP); else while($qryColNP=$qryResultNP->fetchRow()){ echo "<strong>$qryColNP[1]</strong><br />\n"; $sqlNC="SELECT * FROM adminnavlinks WHERE anlANC='$qryColNP[0]' AND anlLive = '1' ORDER BY anlDispName"; $qryResultNC=$db->query($sqlNC); if(DB::isError($qryResultNC=$db->query($sqlNC))) echo DB::errorMessage($qryResultNC); else{ while($qryColNC=$qryResultNC->fetchRow()) echo "<a href=\"$qryColNC[2]\">$qryColNC[1]</a><br />\n"; $qryResultNC->free(); echo "<hr />\n"; } } $qryResultNP->free(); $db->disconnect(); } ?> and the page calling the functions looks like this: <?php require_once('includes/library.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Intranetworks by Evolution</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="includes/main.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="header"><a href="index.php"><img src="images/thinilogo.gif"></a></div> <div id="nav"> <a class="nav" href="<?php echo $_SERVER['PHP_SELF']; ?>?css=main">Regular</a> :: <a class="nav" href="<?php echo $_SERVER['PHP_SELF']; ?>?css=text">Text Only</a> :: <a class="nav" href="<?php echo $_SERVER['PHP_SELF']; ?>?css=large">Large Print</a>&nbsp;</div> <div class="bar"></div> <div id="cframe"> <div class="content"> <?php navdir($rootDir, $dirToList);?> </div> <div class="content"> <?php listdir($dirToList);?> </div> <div id="navAlpha"> <?php drawSiteNavPanel(); ?> </div> <div id="navBeta"> <strong>Administration Menu</strong><br /> <?php drawAdminNavPanel(); ?> </div> </div> </body> </html>

« previous php.pear.general (#4707) next »