Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql MAMP堆栈上运行的CodeIgniter中没有选择数据库错误_Mysql_Database_Codeigniter_Mamp - Fatal编程技术网

Mysql MAMP堆栈上运行的CodeIgniter中没有选择数据库错误

Mysql MAMP堆栈上运行的CodeIgniter中没有选择数据库错误,mysql,database,codeigniter,mamp,Mysql,Database,Codeigniter,Mamp,我在一个常规的MAMP堆栈上安装了ci,我正在处理。但是,我只浏览了Created部分,目前我得到一个No database selected错误 型号: <?php class submit_model extends Model { function submitForm($school, $district) { $data = array( 'school' => $school, 'district

我在一个常规的MAMP堆栈上安装了ci,我正在处理。但是,我只浏览了Created部分,目前我得到一个No database selected错误

型号:

<?php 
class submit_model extends Model {

    function submitForm($school, $district) {
        $data = array(
            'school' => $school,
            'district' => $district
        );

        $this->db->insert('your_stats', $data);
    }

} 
config.php

$config['base_url']    = "http://localhost:8888/ci/";
...
$config['index_page'] = "index.php";
...
$config['uri_protocol']    = "AUTO"; 
那么,它怎么会给我这个错误信息呢

A Database Error Occurred
Error Number: 1046

No database selected

INSERT INTO `your_stats` (`school`, `district`) VALUES ('TJHSST', 'FairFax') 

请尝试将密码留空


我认为这是WAMP和XAMPP的默认设置。它也可以用于MAMP。

我假设您正在自动加载数据库类


再次检查此项,并检查数据库名称是否正确。

No,不幸的是,在启动屏幕中,MAMP显式地将用户名和密码设置为root。您可能需要检查数据库名称。数据库名称与我在database.phpYes中列出的名称匹配,我有$autoload['libraries]=array'database';数据库名stats_test与我通过MAMP在phpMyAdmin中创建的数据库名匹配。您的_stats应该是该数据库中的表。我是不是应该在MAMP里对phpMyAdmin做点特别的事?
$db['default']['hostname'] = "localhost:8889";
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "stats_test";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci"; 
$config['base_url']    = "http://localhost:8888/ci/";
...
$config['index_page'] = "index.php";
...
$config['uri_protocol']    = "AUTO"; 
A Database Error Occurred
Error Number: 1046

No database selected

INSERT INTO `your_stats` (`school`, `district`) VALUES ('TJHSST', 'FairFax')