[eluser]nZac[/eluser]
There is no General Topics forum anymore so I am not sure if this is the right place but I will post it here anyway.
PHP Version: 5.1.6 (I know, old... if it was me we would upgrade today!)
MySQL Version: 5.0.17
CI: 2.0.2
What I am trying to do: Connect to a Database
What I have tried:
Code:
#In CI
#Database Config:
$db['default']['hostname'] = 'Host';
$db['default']['username'] = 'Username';
$db['default']['password'] = 'Password';
$db['default']['database'] = 'Database';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = TRUE;
# Controller
class Register extends CI_Controller {
public function index()
{
echo ($this->db->simple_query('SELECT * FROM users')) ? "YES" : "NO";
}
}
Result: "A Database Error Occured"
Code:
# Not in CI
mysql_connect('host', 'username', 'password');
mysql_select_db('database');
echo mysql_error();
$query = mysql_query('SHOW VARIABLES LIKE "%version%"');
var_dump($query);
while($row = mysql_fetch_array($query))
{ var_dump($row); }
Result: Access denied for user 'username'@'555.55.555.%' to database 'database'
However, I can access the information schema table. This tells me that the credentials I am entering are correct because I get the array:
Quote:array(4) {
[0]=>
string(16) "protocol_version"
["Variable_name"]=>
string(16) "protocol_version"
[1]=>
string(2) "10"
["Value"]=>
string(2) "10"
}
array(4) {
[0]=>
string(7) "version"
["Variable_name"]=>
string(7) "version"
[1]=>
string(24) "5.0.17c-pro-gpl-cert-log"
["Value"]=>
string(24) "5.0.17c-pro-gpl-cert-log"
}
array(4) {
[0]=>
string(15) "version_comment"
["Variable_name"]=>
string(15) "version_comment"
[1]=>
string(32) "MySQL Pro Certified Server (GPL)"
["Value"]=>
string(32) "MySQL Pro Certified Server (GPL)"
}
array(4) {
[0]=>
string(23) "version_compile_machine"
["Variable_name"]=>
string(23) "version_compile_machine"
[1]=>
string(4) "i686"
["Value"]=>
string(4) "i686"
}
array(4) {
[0]=>
string(18) "version_compile_os"
["Variable_name"]=>
string(18) "version_compile_os"
[1]=>
string(12) "pc-linux-gnu"
["Value"]=>
string(12) "pc-linux-gnu"
}
Any thoughts on what could cause this?