I face an error when trying the tutorial of CodeIgniter. When I try the "News section". I get the error
A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\CI\system\database\DB_driver.php
Line Number: 124
I am using XAMPP and my os is windows7(64 bit).
My details in the C:\xampp\htdocs\CI\application\config\database.php are follows
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'xxx';
$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'] = FALSE;
I succeeded When to establish the connection to db with core php.
Somebody help me to resolve this..
Thanks in advance..
Reset XAMPP and check if phpmyadmin working and database 'xxx' exist.
using phpmyadmin create the database..name it xxx
then try loading the site again
Also check the index.php file in the root folder.
Sometimes people will place code here to change which database file it uses based on the domain.. not sure what codeigniter tutorial you are following.
first make sure you load your database library
$autoload['libraries'] = array('database');
then check your default settings to see whether something is missing using.
echo '<pre>';
print_r($db['default']);
echo '</pre>';
Set db_debug to false in your CI's database.php.
Another tip. When locally everything is very very slow, change localhost to 127.0.0.1.
Kamikaze™ - 08 December 2011 06:39 AM
Is your table name in uppercase? Be careful with lowercase and uppercase, I had the same problem.
Try this: $this->db->get(“PROJECT_USERS”);
Related
I have 2 server A (Code) and B (Database). I need to access (connect) A to B. I am using mysql 5.6 phpmyadmin and php running in ubuntu 14.04. All I know is that i need to whitelist a user in phpmyadmin. Since I am new to this, can anyone guide me on this.. I have made changes in database.php in server A as follow
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'IP of Server B';
$db['default']['username'] = 'abc';
$db['default']['password'] = '123';
$db['default']['database'] = 'db1';
$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'] = FALSE;
After doing this change when i run the my server A the following error pops up
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 338
I have even edited /etc/mysql/my.cnf in server B by binding the server's IP.
bind_ip=[Server B IP]
I can not comment so I'll just add it here, first of all, make sure you can access your database server remotely. Under normal circumstances port 3306 will be blocked.
Once all the proper credentials are given in database.php, we need to comment out bind-address=1270.0.1 in /etc/mysql/my.cnf file of Server B. Before that stop mysql and restart it once the editing is done.
I have noticed some unexpected behavior while connecting MySQL Codeigniter
Here is scenario:
-> I configured database library for autoload. (config/autoload.php)
$autoload['libraries'] = array('database', 'session');
-> But after configuring that, I can't open anything. I mean to say, Controller or View.
Have I done something wrong?
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'password';
$db['default']['database'] = 'myfamilyfirst';
$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'] = FALSE;
$db['default']['stricton'] = FALSE;
I tried to set $db['default']['autoinit'] = TRUE; to $db['default']['autoinit'] = FALSE;
Now I can open the pages but unable to connect the database.
Please help.
Probably you are using new xampp or wamp. So it will not support mysql.
Change this
$db['default']['dbdriver'] = 'mysqli'; # Change
In codeignator latest version we need to connect database using Mysqli. So in database file you need to give database driver as mysqli like this,
$db['default']['dbdriver'] = 'mysqli';
New codeignator version have mysqli dbdriver. If we have add mysql instated mysqli then shows following error.
Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
Correct way is : $db['default']['dbdriver'] = 'mysqli';
Please make sure that your database username and password matches. Sometimes, these little things matters a lot.
I'm encountering an error every time I'm connecting to my MS SQL 2005 database using CodeIgniter framework, I'm using PHP 5.6.8 version.`
"Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\my_website\system\database\drivers\sqlsrv\sqlsrv_driver.php
on line 76"
I've already added dll files php_pdo_sqlsrv_56_ts.dll and php_sqlsrv_56_ts.dll to ext folder and on my php.ini, and installed Microsoft SQL Native Client 2012,
this is my code in the sqlsrv_driver.php line 76 -> return sqlsrv_connect($this->hostname, $connection);
I already setup and installed all needed files but still I encounter this error, and NO sqlsrv in phpinfo(), so I created a sample php file to test if I will connect to my database w/out using a framework and its successfully connected in MS SQL database, However it doesn't if I used codeigniter.
Did I miss some code, configuration or software to install? Thanks for usual support!
This is my database.php
$db['default']['hostname'] = 'MY-PC\MSSQL2005';
$db['default']['username'] = 'sa';
$db['default']['password'] = 'password';
$db['default']['database'] = 'MYDB';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$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'] = FALSE;
Error that is getting printed out
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346
I have been looking through all the other questions and nothing seems to work. Still getting this error. All the info in my database.php file matched up to my info on the mysql server that I am running on the command line. I am also using mysqld and mysql.server start. I have tested the connection on the command line with
mysql -h localhost -uroot -p dbname
And that seems to work on my command line, but it is giving me the error above when I am referencing it on a localhost server I have set up with the codeigniter project. What am i doing wrong? I have double and triple checked naming conventions to make sure that it isn't the issue.
Also, I am on OS X Mavericks
my code in the config file is as follows:
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'PASS';
$db['default']['database'] = 'dbname';
$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'] = FALSE;
I have run into this problem frequently myself with CodeIgniter. The usual solution (for me!) is to set 'pconnect' and 'db_debug' to FALSE:
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = FALSE;
I tried to change the following line in my config/database.php file and it worked. (The error your getting means something is wrong with your config/database.php)
'hostname' => '/Applications/MAMP/tmp/mysql/mysql.sock',
Explanation for this behaviour is written here (MySQL on OSX finds mysql.sock wrongly).
Cheers!
I develloping a web-based application with codeigniter and when I try to connect to my oracle entreprise 9g database the framework send me this error:
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant OCI_COMMIT_ON_SUCCESS - assumed 'OCI_COMMIT_ON_SUCCESS'
Filename: database/DB.php
Line Number: 142
I tried different method to connect (classic, oracle specific).
There is my config/database.php file.
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*xxx.xxx.xxx.xxx*)(PORT=1521))(CONNECT_DATA=(SID=*DB_NAME*)))';
$db['default']['username'] = '*username*';
$db['default']['password'] = '*password*';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'oci8';
$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'] = FALSE;
I think it's not a connection error, can you help me?
OCI_COMMIT_ON_SUCCESS is a constant declared in the Oracle PHP extension. Are you sure you have that installed correctly? Is it enabled in php.ini? Can you confirm that you can connect to the database manually with oci_connect?
If you don't have the extension, then you'll need to install it. There is a list of steps I generally take to debug the installation here.
I'm not sure what the value of OCI_COMMIT_ON_SUCCESS is, but you might be able to fake it with your own define, if it comes to that.