7

Can someone help me?

I am a beginner and trying to make wearing CodeIgniter authentication, but when I try to make an error like this

A Database Error Occurred

Error Number: 1046

No database selected

SELECT * FROM (`user`) WHERE `user_username` = 'amanda' AND user_passwordMD5("12345") =

Filename: C:\xampp\htdocs\codeigniter\system\database\DB_driver.php

Line Number: 330

thanx

Subodh Ghulaxe
  • 18,333
  • 14
  • 83
  • 102
Revoir Hz
  • 73
  • 1
  • 1
  • 7

5 Answers5

3

please make sure you have setup database configuration in application/config/database.php file

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'my_database';
Laukik Patel
  • 733
  • 7
  • 18
2

Check the database.php file in application/config/

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'my_database'; // here is the database selection
ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42
  • 1
    I have tried it and then appear again error like this A Database Error Occurred Unable to select the specified database: authtentication Filename: C:\xampp\htdocs\codeigniter\system\database\DB_driver.php Line Number: 140 – Revoir Hz Apr 05 '14 at 07:15
  • have you specified the db on database.php – ReNiSh AR Apr 05 '14 at 07:23
  • $db['default']['hostname'] = 'localhost'; $db['default']['username'] = ''; $db['default']['password'] = ''; $db['default']['database'] = 'authtentication'; $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; sorry – Revoir Hz Apr 05 '14 at 07:24
0

Open the file 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.

martianwars
  • 6,380
  • 5
  • 35
  • 44
0

Lost connection to MySQL server during query Line Number: 337

Vaibhav V. Joshi
  • 175
  • 3
  • 14
-1

people who critic here should have not only education but also common sense. they should know also what time I made this comment and what was my reputation score. It is not only about giving an answer but the giving also the suggestion a beginner can pin-point the problem. I could have given the answer but just after posting my comment someone already given answer. Look below - best among anyone given here

$config['hostname'] = "localhost";
$config['username'] = "username";
$config['password'] = "password";
$config['database'] = "database";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
user3470953
  • 11,025
  • 2
  • 17
  • 18