[eluser]Unknown[/eluser]
So I'm working on a database related project with CI as a the framework. So far, everything has been fine, since I've been developing on local host. I moved the project over to a remote server and noticed that things were failing.
As I was trying to isolate the error, I noticed that queries didn't work. That is, they didn't return a MySQL error or any results. The queries themselves were fine and should have returned results (I tested in phpMyAdmin to make sure).
I tried to get CodeIgniter to tell me what the MySQL error was with
Code:
$this->db->_error_message()
But that returned the following error message:
Quote:A PHP Error was encountered
Severity: Warning
Message: mysqli_error() expects parameter 1 to be mysqli, boolean given
Filename: mysqli/mysqli_driver.php
Line Number: 481
So I investigated further, by going into mysqli_driver.php and the function mysqli_error(). The function expects the parameter called $conn_id to be mysqli, but instead was receiving a boolean value (probably FALSE), which tells me that the connection was failing.
I tried a number of proposed solutions from Stack Overflow and other posts on these forums but nothing worked. Some of the things I tried included disabling/enabling database autoload, disabling/enabling persistent connection, etc. I even ran this code that was recommended on Stack Overflow:
Code:
echo '<pre>';
print_r($db['default']);
echo '</pre>';
echo 'Connecting to database: ' .$db['default']['database'];
$dbh=mysql_connect
(
$db['default']['hostname'],
$db['default']['username'],
$db['default']['password'])
or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db['default']['database']);
echo '<br /> Connected OK:' ;
die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);
From this, I got "
Connected OK" which really puzzled me, since I was obviously not connecting okay.
I've exhausted all the solutions that I've come across and would really appreciate some help. Thanks in advance.