"发生错误应用程序错误" Zend身份验证

时间:2014-12-28 09:52:46

标签: php ubuntu zend-framework zend-db-table

我正在关注here的教程。最后,当我无法正确完成时,我只是下载了there给出的代码。

我的 application.ini 文件是

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.db.adapter = "Pdo_Mysql"
resources.db.params.charset = "utf8"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "mypassword"
resources.db.params.dbname = "zf2tutorial"


[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

我用它来运行服务器

sudo php -S 0.0.0.0:8080 -t public/ public/index.php

当我进入浏览器并将网址设为http://0.0.0.0:8080/并输入用户名为“admin”并输入密码为“password”时,我就

An error occurred
Application error
Exception information:

Message: The supplied parameters to Zend_Auth_Adapter_DbTable failed to produce a valid sql statement, please check table and column names for validity.
Stack trace:

#0 /usr/share/php/Zend/Auth/Adapter/DbTable.php(369): Zend_Auth_Adapter_DbTable->_authenticateQuerySelect(Object(Zend_Db_Select))
#1 /usr/share/php/Zend/Auth.php(117): Zend_Auth_Adapter_DbTable->authenticate()
#2 /var/www/html/zf-auth-tutorial/application/controllers/AuthController.php(33): Zend_Auth->authenticate(Object(Zend_Auth_Adapter_DbTable))
#3 /var/www/html/zf-auth-tutorial/application/controllers/AuthController.php(16): AuthController->_process(Array)
#4 /usr/share/php/Zend/Controller/Action.php(516): AuthController->indexAction()
#5 /usr/share/php/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('indexAction')
#6 /usr/share/php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#7 /usr/share/php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#8 /usr/share/php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#9 /var/www/html/zf-auth-tutorial/public/index.php(26): Zend_Application->run()
#10 {main}  

Request Parameters:

array (
  'controller' => 'auth',
  'action' => 'index',
  'module' => 'default',
  'username' => 'admin',
  'password' => 'ad',
  'login' => 'Login',
)  

我的SQL

CREATE TABLE IF NOT EXISTS users (
  id int(11) NOT NULL AUTO_INCREMENT,
  username varchar(50) NOT NULL,
  password varchar(50) NOT NULL,
  salt varchar(50) NOT NULL,
  role varchar(50) NOT NULL,
  date_created datetime NOT NULL,
  PRIMARY KEY (id)
)

并插入记录

INSERT INTO users (username, password, salt, role, date_created) 
VALUES ('admin', SHA1('passwordce8d96d579d389e783f95b3772785783ea1a9854'),
    'ce8d96d579d389e783f95b3772785783ea1a9854', 'administrator', NOW());

这些查询与教程一致。

有人能告诉我错误吗? 我不确定 resources.b 文件中 resources.db.params.charset =“utf8”是否正确。

1 个答案:

答案 0 :(得分:0)

经过一些研究和Kervin在this帖子的回答后,我才知道

删除' utf-8' application.ini中的charset为我解决了这个问题。,来自Kervin的回答这句话为我做了。