在YII框架中登录错误
问题描述:
我是新来的美丽的Yii框架。所以我只是阅读教程和文档。所以我从开始做博客教程。因此,对于博客应用程序,我将数据库从Yii附带的博客文件夹导出到MySQL。我再次决定使用Yii用户模块,为此我将用户模块数据库导出到MySQL。现在我的问题是,当我在应用程序中使用的登录它显示像这样在YII框架中登录错误
Trying to get property of non-object
我都试过index.php?r=site/login
,也index.php?r=user/login
都失败了一些错误。那么有人能告诉我如何解决这个问题。 FYI在我的数据库中有两个字段,如从博客文件夹导入的'ia_user'和从Yii用户模块文件夹导入的'ia_users'。那么是否有任何错误。下面我粘贴main.php文件的配置。
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Blog Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
/*user module starts here*/
'application.modules.user.models.*',
'application.modules.user.components.*',
/*user module ends here*/
),
'modules'=>array(
// uncomment the following to enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
/*user module starts here*/
'loginUrl' => array('/user/login'),
/*user module ends here*/
),
// uncomment the following to enable URLs in path-format
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
//'db'=>array(
// 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=tbl_blog',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'tablePrefix'=> 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'[email protected]',
),
);
请帮我out.Any帮助和建议将成为高度appreciable.I要求从Yii的论坛上的帮助,但没有得到任何答复所以我要求帮助这里。
答
我不得不模块的阵列添加用户就这样
'user'=>array(
'user'
// enable cookie-based authentication
'allowAutoLogin'=>true,
/*user module starts here*/
'loginUrl' => array('/user/login'),
/*user module ends here*/
),
我真的知道_nothing_这个框架,但我在config看到这一点:'/ *用户模块从这里开始* /“loginUrl” => array('/ user/login'),',也许你可以试试:index.php?r =/user/login - 但超越那个好运! –
您看到的错误应该有一个文件名和行。查看该代码,找到错误。然后继续找到那个地方,那个错误的原因是什么。修复原因。这就是所谓的调试,你在问题中发布的代码只是你网站的一小部分,所以很难说。请参阅[尝试获取非对象的属性](http://*.com/questions/3304904/trying-to-get-property-of-non-object) – hakre
尝试替换loginUrl“/ user/login “到”用户/登录“(没有”/“符号)。并给出更具体的日志消息,因为你应该看到你无法获得某个对象的属性。 –