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