Codeigniter : Showing error as ' Unable to select the specified database: project' in Windows XP
Asked Answered
R

5

7

I am using Windows XP and using EasyPHP as a server. I have integrated Codeigniter with TankAuth. But, when I try to open my assignment folder, it shows error as follows:

Unable to select the specified database: project

Filename: C:\Program Files\EasyPHP-12.1\www\assignment\system\database\DB_driver.php

Line Number: 140

The code inside my database .php is as follows"

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'root123';
$db['default']['database'] = 'project';
$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 checked my database.php, inside it I have database name as 'project'.

I have tried with hostname both as 'localhost' and as '127.0.0.1', but none worked.

I have set my default controller to 'auth' i.e. default controller of TankAuth.

And have initialized 'database' library in the construct in 'auth' controller.

Just now I have tried the same thing using Wamp Server. But, got the same result.

Somewhere I read that I should try making $db['default']['pconnect'] and

$db['default']['db_debug'] to FALSE. But it didn't work.

And all the access permissions have been granted to database 'project'.

Is there anything that I should try to make it work?

Thanks in advance...

Razorbill answered 19/3, 2013 at 15:32 Comment(3)
Somewhere you are trying to load a database named "project"...are you doing this in the controller?Isola
@DevinYoung No, I havn't loaded any database in controller 'auth.php'Razorbill
Hi, Are you fix this problem?.. Now i have this problem, Please tell me how to rectifyFermanagh
J
11

The error is stating that it has successfully connected to your database software, but it cannot find the specified DB named project. Check your DB connections and make sure they are all correct -- it sounds like your database name should be assignment instead.

Edit: Check to make sure the DB user your are logging in as has permission to access the specified database, also.

Jolynjolynn answered 19/3, 2013 at 19:39 Comment(4)
Sorry bro for misleading you. It was my mistake to write a wrong question. Actually 'assignment' is the name of my Codeigniter folder. And the database name in config file 'database.php' is 'project'. And database with same name is also present in my MYSQL databaseRazorbill
See revised note about DB user permission.Jolynjolynn
I have verified that the database project has all DB access permissionsRazorbill
I couldn't speculate because I don't develop on a Windows machine. Try going through some of EasyPHP's FAQ and see if anything doesn't match your setup and fix it.Jolynjolynn
C
20

I was facing a similar problem but unfortunately none of the answers on any site helped. The weird thing was that I was easily able to connect to MySQL using simple PHP but in CodeIgniter I was getting this message.

Finally this solved my problem. Open the application/config/database.php file and change the following line:

$db['default']['dbdriver'] = 'mysql';

To:

$db['default']['dbdriver'] = 'mysqli';

This shift to mysqli saved by day.

Creditor answered 3/8, 2013 at 5:44 Comment(1)
Thanks, It worked. xD... Dnt know why and how, but your solution worked for me.. :) It was working before, but not sure why it stopped working in the first place.Bogus
J
11

The error is stating that it has successfully connected to your database software, but it cannot find the specified DB named project. Check your DB connections and make sure they are all correct -- it sounds like your database name should be assignment instead.

Edit: Check to make sure the DB user your are logging in as has permission to access the specified database, also.

Jolynjolynn answered 19/3, 2013 at 19:39 Comment(4)
Sorry bro for misleading you. It was my mistake to write a wrong question. Actually 'assignment' is the name of my Codeigniter folder. And the database name in config file 'database.php' is 'project'. And database with same name is also present in my MYSQL databaseRazorbill
See revised note about DB user permission.Jolynjolynn
I have verified that the database project has all DB access permissionsRazorbill
I couldn't speculate because I don't develop on a Windows machine. Try going through some of EasyPHP's FAQ and see if anything doesn't match your setup and fix it.Jolynjolynn
J
2

Maybe this will save someone sometime - I was using cPanel and it has a certain rule that a user has to be tied to a database to access it. I was getting the same error, but because I did not have the permissions, I could not access it.

In cPanel go to MySQL Databases, find your user and add this user to your database.

Jinn answered 28/2, 2016 at 1:11 Comment(0)
H
1

Try this: just refresh the db software. If you are using PHPMy Admin, refresh the page and try loading your PHP page. or if you have any stored procedure in your db, this may cause the problem. try removing the stored procedures.

Hinge answered 20/4, 2013 at 9:53 Comment(0)
S
0
Notice: SQL safe mode in effect – ignoring host/user/password information in
mysql_connect(): SQL safe mode in effect – ignoring host/user/password information in
This is caused due to your php.ini sql safe mode settings.
Login your php.ini file.
Go php.ini from apache and turn off sql.safe mode.

[SQL]
sql.safe_mode  = Off
Restart apache
Saloma answered 11/12, 2016 at 4:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.