I'm currently switching all the mysql_* functions to mysqli_* functions and i am getting the following errors .
PHP Warning: mysqli_connect(): (HY000/1040): Too many connections in
PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in
PHP Warning: mysqli_error() expects parameter 1 to be mysqli, boolean
In config.php :
$dbuser = "xxx";
$dbpass = "xxx";
$dbhost = "xxxx";
$dbname = "xxxxxx";
$connection = mysqli_connect($dbhost, $dbuser, $dbpass) or die("could not connect to mysql");
if($connection){
echo "\n Database connected ....\n\n";
}
mysqli_select_db($connection,$dbname) or die(mysqli_error($connection));
In other.php
require_once 'Lib/config.php';
class Mutex {
protected $connection;
public function __construct()
{
global $dbuser,$dbpass,$dbname,$dbhost; // globally declaring the config variables
$this->connection = mysqli_connect($dbhost, $dbuser, $dbpass,$dbname);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
//you need to exit the script, if there is an error
exit();
}
}
public function Prog($pack = null) {
if(isset($pack) && $pack != "") {
$sql_qry = "SELECT id from xxxx WHERE package like '" . addslashes($pack) . "'";
showSqlQuery($sql_qry);
$result = mysqli_query($this->connection,$sql_qry)or die(mysqli_error($this->connection));
if($result && mysqli_num_rows($result)>0) {
$row = mysqli_fetch_assoc($result);
if(!empty($row)) {
return "Exists";
}
}
return "NotExists";
}
return "InvalidProcess";
}
}
Tried many solutions, but none of them worked for me
Getting errors as shown above. Please help me to solve this..
Thanks in advance.