0

A Database Error Occurred

Error Number: 1046

No database selected

SELECT * FROM ts_themes WHERE theme_status = 1

Filename: C:/xampp/htdocs/Themeportal/application/models/DatabaseModel.php

Line Number: 23

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Please provide more information about your environment or what you are trying to do. – davidmatas Feb 04 '17 at 19:11
  • Follow the class and file naming way for codeigniter https://www.codeigniter.com/user_guide/general/styleguide.html#file-naming `Database_model.php` and `class Database_model extends CI_Model {}` –  Feb 04 '17 at 20:01

2 Answers2

1

Manage your database setting in application/config/database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
'dsn'      => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'database_name',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt'  => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
 );
Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19
  • A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/1049): Unknown database '' Filename: mysqli/mysqli_driver.php Line Number: 202 Backtrace: File: C:\xampp\htdocs\Themeportal\application\controllers\Home.php Line: 8 Function: __construct File: C:\xampp\htdocs\Themeportal\index.php Line: 318 Function: require_once A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: C:/xampp/htdocs/Themeportal/application/controllers/Home.php Line Number: 8 – Vikram Rana Feb 04 '17 at 16:02
  • set like this `'database' => 'studentsnotes',` – Hikmat Sijapati Feb 04 '17 at 16:04
  • A PHP Error was encountered Severity: Warning Message: file_get_contents(C:\xampp\htdocs\Themeportal\application\controllersapplication/config/verify.txt): failed to open stream: No such file or directory Filename: controllers/Default_controllers.php Line Number: 4 Backtrace: File: C:\xampp\htdocs\Themeportal\application\controllers\Default_controllers.php Line: 4 Function: file_get_contents File: C:\xampp\htdocs\Themeportal\application\controllers\Home.php Line: 20 Function: require File: C:\xampp\htdocs\Themeportal\index.php Line: 318 Function: require_once – Vikram Rana Feb 04 '17 at 16:08
  • could you post your application\controllers\Home.php?check there you have error in `require_once`. – Hikmat Sijapati Feb 04 '17 at 16:11
0

first configure your database setting application/config/database.php

then your query will be

    $this->db->select('*');
    $this->db->from('ts_themes');
    $this->db->where('theme_status',"1");
    $query=$this->db->get();
    return $query->result();
Parvez Ahmed
  • 650
  • 7
  • 16