运行php index.php控制台迁移后出错

vd2z7a6w  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(364)

我想在codeigniter中进行数据库迁移,但出现了以下错误

c:\xampp\htdocs\r_project>php index.php console migrate
PHP Notice:  Undefined index: HTTP_HOST in C:\xampp\htdocs\r_project\application
\config\config.php on line 43

Notice: Undefined index: HTTP_HOST in C:\xampp\htdocs\r_project\application\conf
ig\config.php on line 43

A PHP Error was encountered

Severity:    Notice
Message:     Undefined index: HTTP_HOST
Filename:    C:\xampp\htdocs\r_project\application\config\config.php
Line Number: 43

Backtrace:
        File: C:\xampp\htdocs\r_project\application\config\config.php
        Line: 43
        Function: _error_handler

        File: C:\xampp\htdocs\r_project\index.php
        Line: 316
        Function: require_once

ERROR: An Error Was Encountered

        You have not specified a database connection group via $active_group in
your config/database.php file.

我已经用这个设置了config.php

$isSSL = function(){
    if( !empty( $_SERVER['https'] ) )
        return true;

    if( !empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )
        return true;

    if ( !isset($_SERVER['SERVER_PORT']))
        return false;

    if( $_SERVER['SERVER_PORT'] == 443)
        return true;

    return false;
};

$prot = $isSSL() ? 'https://' : 'http://';
$host = $_SERVER["HTTP_HOST"];
$config['base_url'] = $prot . $host . "/";

除此之外。我必须在文件夹\application\config\development\database.php中设置database.php文件
我该怎么办。真的需要帮助

js81xvg6

js81xvg61#

就你所得到的错误而言,试试这个:

$host = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);

在设置数据库配置文件方面,我们需要知道更多信息才能回答。

相关问题