Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4626374
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:24:39+00:00 2026-05-22T03:24:39+00:00

Trying to make a setup for my application. However, I am having trouble getting

  • 0

Trying to make a setup for my application. However, I am having trouble getting it to create the database for me.

If I create the database manually, everything is fine.
If the database is not there, I can’t do anything, and I get the following error:

A Database Error Occurred
Unable to select the specified database: my_db

Filename: core/Loader.php

Line Number: 232

I’m following the dbutil guide.
My code:

    function index()
    {
      $db_exists = FALSE;
      $this->load->dbutil();
      if(  $this->dbutil->database_exists( 'my_db' ) ){
        $db_exists = TRUE;
      }
    } 

As per the guide, I get my database driver running in application/config/autoload.php

$autoload['libraries'] = array( 'database', 'datamapper' );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:24:40+00:00Added an answer on May 22, 2026 at 3:24 am

    Is your database already specified in the database.php config file?

    What you will likely need to do is set your connection settings and leave the database name blank

    $db['default']['database'] = '';
    

    Then you can still autoload the database class and then load the dbutil class to check it. After checking and/or creating you would need to set the database name back in the database.php config.

    Alternatively, you could remove the database class from autoload and load it on each controller needed. Then, in your installer controller you can load it without the database name using either a DSN or $config array according to the docs: http://www.codeignitor.com/user_guide/database/connecting.html

    function index()
    {
      $dsn = 'mysql://myuser:mypass@localhost';
      $this->load->database($dsn);
      $this->load->dbutil();
      $db_exists = FALSE;
      $this->load->dbutil();
      if(  $this->dbutil->database_exists( 'my_db' ) ){
        $db_exists = TRUE;
      }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a setup program for an ASP.NET web site. I need
Trying to make a MySQL-based application support MS SQL, I ran into the following
I'm trying to create a separator line in my android view. The setup I
I'm trying to build some iOS apps while learning and am having some trouble
Trying to make a make generic select control that I can dynamically add elements
Trying to make a generic PL/SQL procedure to export data in specific XML format,
Trying to make a web service call to an HTTPS endpoint in my Silverlight
I'm trying to make the case for click-once and smart client development but my
I'm trying to make a data bound column invisible after data binding, because it
I'm trying to make a context menu for a control that is linked to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.