Jump to content

jesbin

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jesbin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The error I get is Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Work\IPCC\Search.php\classes\class.DataManager.php on line 189 Array ( ) This is always the case for the second call. If I switch then around I get it for the second one. The workaround I did was to close the mysql connection, which is not what I wanted to do private static function _getConnection($dbname = 'wgexpert') { if (isset(self::$link)) { mysql_close(self::$link); // THIS HAD TO BE DONE } self::$link = mysql_connect('localhost', 'root', '', true ); $db = mysql_select_db('wgexpert') or die('Failure to access the database'); //echo "cn: " . self::$link . "<br>"; return (self::$link); }
  2. I've a DataManager class which looks like the following <?php class DataManager { protected static $link; private static function _getConnection($dbname = 'wgexpert') { if (isset(self::$link)) return self::$link; self::$link = mysql_connect('localhost', 'root', '' ); $db = mysql_select_db('wgexpert') or die('Failure to access the database'); return (self::$link); } public static function getcountries() { $sql = "call spGetCountries();"; $countries = array(); $result = mysql_query($sql, DataManager::_getConnection()); while ($row = mysql_fetch_array($result)) { $countries[$row["countryID"]] = $row["countryName"]; } return ($countries); } public static function getNominators($name, $org, $country) { $sql = "call spSearchNominator('$name', '$org', $country);"; $res = mysql_query($sql, DataManager::_getConnection()); while ($row = mysql_fetch_array($res)) { / * do something */ } } } ?> There there is a php page which calls two of the method of the class require_once("classes/class.DataManager.php"); $data = DataManager::getcountries(); print_r($data); DataManager::getNominators ("b", "", 0); If I call both of then I get the error while calling the second method. If I comment out one of them (any one), it is fine. I cannot figure out what is going on Jesbin
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.