Welcome Guest, Not a member yet? Register   Sign In
unable to select specified database error
#1

[eluser]Harsh[/eluser]
Hi,

i am facing a error but i am not able to know the exact region.
sometimes once i want to login it is giving me error "unable to select specified database :database name".

once i have modified the DB_driver.php in database folder it is working fine.For that i have commented that area(marked in red)and there i have written connection string then it is working.

I have done something like this:-

// Select the DB... assuming a database name is specified in the config file
if ($this->database != '')

{
if ( ! $this->db_select())
{

log_message('error', 'Unable to select database: '.$this->database);

/*if ($this->db_debug)
{
$this->display_error('db_unable_to_select', $this->database);
}
*/

$conn=mysql_connect("localhost","root","") or die("unable to connect localhost".mysql_error());
$this->conn_id = $conn;
$db=mysql_select_db("egoalsheet",$conn) or die("unable to select egoalsheet");
return TRUE;
}

so anyone please guide me to comeout with this issue.

Thanks
Harsh
#2

[eluser]InsiteFX[/eluser]
Did you setup application/config/database.php with the correct parameters?
#3

[eluser]Harsh[/eluser]
Yes i have done that,
find the example
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "HOSTNAME";
$db['default']['username'] = "USERNAME";
$db['default']['password'] = "PASSWORD";
$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";

Thanks
Harsh
#4

[eluser]toopay[/eluser]
Is that the actual code? You must fill-out hostname, username, password and database name corectly! Then, make sure the database is exist on your computer and you already created user with apropriate access.

PS : Also, please use code tags when posting your code.
#5

[eluser]Harsh[/eluser]
actually we are using wamp server. (Windows)
We have already probed into the fact of too many connections , sleep connections in mysql and hence restarted WAMP last nite. The server was up and running for say 3 hours and then again went down with the same error midnight. we had to revoke our patch to make it up.

So back to square one, we right now have no clue about it, please suggest the probable areas we can look into.
OR if anyone has faced similar issue.

Thanks
Harsh
#6

[eluser]InsiteFX[/eluser]
You should not be modifying the database driver!
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "Localhost";
$db['default']['username'] = "USERNAME";  // phpMyAdmin username
$db['default']['password'] = "PASSWORD";  // phpMyAdmin password
$db['default']['database'] = "DBNAME";    // your database name you created in phpMyAdmin
$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";
Your getting the error because your database parameters are wrong above!

This is all wrong! You do not need any of this!
application/config/autoload.php - load the database!
Code:
$conn=mysql_connect(“localhost”,“root”,”“) or die(“unable to connect localhost”.mysql_error());
$this->conn_id = $conn;
$db=mysql_select_db(“egoalsheet”,$conn) or die(“unable to select egoalsheet”);
return TRUE;

InsiteFX
#7

[eluser]toopay[/eluser]
@Hars
Please, dont take what i or InsiteFX mention above, in wrong way. But, it seems to us, that you didn't really set your database properly. This turorial will give you a quick start, to PHP MYSQL, after you read that, try that, then still have a problems, you can back to this forums and we'll loved to help you.
#8

[eluser]Harsh[/eluser]
I am not taking your suggestion in wrong way..

The current scenario is this:

we are giving host name as "localhost".
username as "root" and
password filed we are leaving blank("").

is that error coming because we have left password filed as blank?
if this is the cause why this is working fine early?

is there any codeigniter inbuilt library issue for database?

from the above comment if you find any database setup issue please guide me
and give me the concrete solution

Thanks
Harsh
#9

[eluser]InsiteFX[/eluser]
The password is the password you used when creating the database in MyPhpAdmin or whatever you used!

InsiteFX
#10

[eluser]Ken Verhaegen[/eluser]
[quote author="InsiteFX" date="1304344854"]The password is the password you used when creating the database in MyPhpAdmin or whatever you used!

InsiteFX[/quote]
PHPMyAdmin*

And WAMP uses a blank password on install.




Theme © iAndrew 2016 - Forum software by © MyBB