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


"An error occurred Application error" Zend Authentication

我正在从这里学习教程。最后,当我无法正确完成时,我只是下载了那里给出的代码。

我的应用程序.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

当我进入浏览器并将URL作为http://0.0.0.0:8080/输入用户名和密码作为"密码"时,我得到

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.db.params.charset = "utf8"应用程序.ini文件中是否正确。

经过一些研究和Kervin对这篇文章的回答,我开始知道

删除应用程序中的"utf-8"字符集.ini为我解决了这个问题,Kervin答案中的这一行为我解决了这个问题。