user1982860
user1982860

Reputation: 1

Data is not inserted into database of production site

My data is not inserted into the database on the production site, while it is working correct on my local testing site. My configuration of codeigniter is correct. If I manually execute the query in the database, it shows the correct message and the data get's inserted into the database.*) When I print the query, it is as expected too.

I think it is a server configuration issue. I am using go daddy and mysql.

Database configuration:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'etc';
$db['default']['password'] = 'etc';
$db['default']['database'] = 'ieshopif_y';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$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;

*) After manually executing the query, I get this success message:

Connecting to database: ieshopif_y
Connected OK:file: /home/ieshopif/public_html/application/config/database.php Line: 82

I'd like to know how I have to configure the database to make it work, if it is a database issue.

Upvotes: 0

Views: 160

Answers (1)

thiagobraga
thiagobraga

Reputation: 1561

These options could be different in production, development and testing:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'etc';
$db['default']['password'] = 'etc';
$db['default']['database'] = 'ieshopif_y';

I suggest you separate this with an ENVIRONMENT constant defined on index.php, because the hostname could be different in production server. Try this:

if (defined('ENVIRONMENT')) {
  switch (ENVIRONMENT) {
    case 'development':
      $db['default']['hostname'] = 'localhost';
      $db['default']['username'] = 'username';
      $db['default']['password'] = 'password';
      $db['default']['database'] = 'ieshopif_y';
      break;

    case 'testing':
    case 'production':
      $db['default']['hostname'] = 'domain.com';
      $db['default']['username'] = 'root';
      $db['default']['password'] = 'secure_pass';
      $db['default']['database'] = 'ieshopif_y';
      break;

    default:
      exit('The application environment is not set correctly.');
  }
}

Upvotes: 2

Related Questions