Php YII框架中的登录错误
我是新来的美丽的Yii框架。所以我只是浏览一下教程和文档。所以我从一开始就在做博客教程。所以对于blog应用程序,我将数据库从blog文件夹中导出,该文件夹随Yii一起提供给MySQL。我再次决定使用Yii用户模块,为此我将用户模块数据库导出到MySQL。现在我的问题是,当我在应用程序中使用login时,它会显示一些类似这样的错误Php YII框架中的登录错误,php,mysql,yii,Php,Mysql,Yii,我是新来的美丽的Yii框架。所以我只是浏览一下教程和文档。所以我从一开始就在做博客教程。所以对于blog应用程序,我将数据库从blog文件夹中导出,该文件夹随Yii一起提供给MySQL。我再次决定使用Yii用户模块,为此我将用户模块数据库导出到MySQL。现在我的问题是,当我在应用程序中使用login时,它会显示一些类似这样的错误 Trying to get property of non-object 我都尝试了index.php?r=site/login,而且index.php?r=use
Trying to get property of non-object
我都尝试了index.php?r=site/login
,而且index.php?r=user/login
都失败了。有人能告诉我怎么解决这个问题吗。仅供参考在我的数据库中有两个字段,如从博客文件夹导入的“ia_用户”和从Yii用户模块文件夹导入的“ia_用户”。那么有什么不对劲吗。下面我粘贴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'=>'webmaster@example.com',
),
);
我必须像这样在模块数组中添加用户
'user'=>array(
'user'
// enable cookie-based authentication
'allowAutoLogin'=>true,
/*user module starts here*/
'loginUrl' => array('/user/login'),
/*user module ends here*/
),
我对这个框架一无所知,但我在配置文件中看到:/*用户模块从这里开始*/'loginUrl'=>数组('/user/login'),
,也许你可以试试:index.php?r=/user/login-但除此之外,祝你好运!您看到的错误也应该有文件名和行。查看该代码,找到错误。然后继续,找出错误的原因所在。找出原因。这叫做调试,你在问题中发布的代码只是你网站的一小部分,所以很难说。请参见尝试将loginUrl“/user/login”替换为“user/login”(无“/”符号)。并给出更具体的日志消息,因为您应该看到在哪里无法获取某个对象的属性。