連接數(shù)據(jù)庫出錯1046:No database selected [ SQL語句 ] : SELECT * FROM `think_user`
運(yùn)行user方法時,無法連接數(shù)據(jù)庫。
出錯提示
數(shù)據(jù)庫配置:
<?php return?array?( 'DB_TYPE'?=>?'mysql',?//?數(shù)據(jù)庫類型 'DB_HOST'?=>?'localhost',?//?服務(wù)器地址 'DB_NAME'?=>?'user',?//?數(shù)據(jù)庫名 'DB_USER'?=>?'root',?//?用戶名 'DB_PWD'?=>?'',?//?密碼 'DB_PORT'?=>?'3306',?//?端口 'DB_PREFIX'?=>?'mk_'? )?//?數(shù)據(jù)庫表前綴 ;
方法調(diào)用:
<?php //?本類由系統(tǒng)自動生成,僅供測試用途 class?IndexAction?extends?Action?{ public?function?index()?{ echo?'333333'; //?$this->show('<style?type="text/css">*{?padding:?0;?margin:?0;?}?div{?padding:?4px?48px;}?body{?background:?#fff;?font-family:?"微軟雅黑";?color:?#333;}?h1{?font-size:?100px;?font-weight:?normal;?margin-bottom:?12px;?}?p{?line-height:?1.8em;?font-size:?36px?}</style><div?style="padding:?24px?48px;">?<h1>:)</h1><p>歡迎使用?<b>ThinkPHP</b>!</p></div><script?type="text/javascript"?src="http://tajs.qq.com/stats?sId=9347272"?charset="UTF-8"></script>','utf-8'); } public?function?user()?{ $user?=?new?Model?(?'user'?); $data?=?$user->select?(); dump?(?$data?); //?$model?=M(); //?$data=$model->query('select?*?from?mk_user'); //?//?dump($data); //?echo?c('name'); //?trace('name',C('name')); $this->display?(); } }
index.php:
<?php define?(?'APP_DEBUG',?TRUE?); define?(?'APP_NAME',?'App'?); define?(?'APP_PATH',?'./App/'?); require?('./ThinkPHP/ThinkPHP.php');
debug.php:
<?php return?array?( 'name'?=>?'Donsen@debug', 'SHOW_PAGE_TRACE'?=>?true? )?//?顯示頁面trace信息 ;
明明已經(jīng)配置了數(shù)據(jù)庫,但是顯示沒有連接數(shù)據(jù)庫。
2017-02-19
兄弟 ?我剛弄清楚了 ?要把那個前綴設(shè)置成空
2016-10-05
用mysqli還是一樣的出錯
2016-10-05
用mysqli擴(kuò)展試試