timeless 发表于 2017-5-8 11:10:36

总是提示连接不上数据库

A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: D:\phpStudy\WWW\qingjia\system\database\DB_driver.php

Line Number: 125

timeless 发表于 2017-5-8 11:11:23

class CI_DB_driver {

        var $username;
        var $password;
        var $hostname;
        var $database;
        var $dbdriver                = 'mysql';
        var $dbprefix                = '';
        var $char_set                = 'utf8';
        var $dbcollat                = 'utf8_general_ci';
        var $autoinit                = TRUE; // Whether to automatically initialize the DB
        var $swap_pre                = '';
        var $port                        = '';
        var $pconnect                = FALSE;
        var $conn_id                = FALSE;
        var $result_id                = FALSE;
        var $db_debug                = FALSE;
        var $benchmark                = 0;
        var $query_count        = 0;
        var $bind_marker        = '?';
        var $save_queries        = TRUE;
        var $queries                = array();
        var $query_times        = array();
        var $data_cache                = array();
        var $trans_enabled        = TRUE;
        var $trans_strict        = TRUE;
        var $_trans_depth        = 0;
        var $_trans_status        = TRUE; // Used with transactions to determine if a rollback should occur
        var $cache_on                = FALSE;
        var $cachedir                = '';
        var $cache_autodel        = FALSE;
        var $CACHE; // The cache class object

        // Private variables
        var $_protect_identifiers        = TRUE;
        var $_reserved_identifiers        = array('*'); // Identifiers that should NOT be escaped

        // These are use with Oracle
        var $stmt_id;
        var $curs_id;
        var $limit_used;



        /**
       * Constructor.Accepts one parameter containing the database
       * connection settings.
       *
       * @param array
       */
        function __construct($params)
        {
                if (is_array($params))
                {
                        foreach ($params as $key => $val)
                        {
                                $this->$key = $val;
                        }
                }

                log_message('debug', 'Database Driver Class Initialized');
        }

        // --------------------------------------------------------------------

        /**
       * Initialize Database Settings
       *
       * @access        private Called by the constructor
       * @param        mixed
       * @return        void
       */
        function initialize()
        {
                // If an existing connection resource is available
                // there is no need to connect and select the database
                if (is_resource($this->conn_id) OR is_object($this->conn_id))
                {
                        return TRUE;
                }

                // ----------------------------------------------------------------

                // Connect to the database and set the connection ID
                $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();

                // No connection resource?Throw an error
                if ( ! $this->conn_id)
                {
                        log_message('error', 'Unable to connect to the database');

                        if ($this->db_debug)
                        {
                                $this->display_error('db_unable_to_connect');
                        }
                        return FALSE;
                }

timeless 发表于 2017-5-8 11:11:43

这是125行$this->display_error('db_unable_to_connect');

Hex 发表于 2017-5-8 14:16:12

timeless 发表于 2017-5-8 11:11
这是125行$this->display_error('db_unable_to_connect');

你的数据库配置不对,你先确定你用 PHP 能不能连接数据库?
页: [1]
查看完整版本: 总是提示连接不上数据库