dongshi1934 2013-07-26 18:18
浏览 35

数据未插入生产站点的数据库中

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.

  • 写回答

1条回答 默认 最新

  • dongyue9864 2013-07-26 19:39
    关注

    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.');
      }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号