我是CodeIgniter的新用户。我使用CodeIgniter 3.1.3并且几乎在2周之前一直在努力解决这个随机定时未知的神秘致命错误:
P.S。 1)我已经使用CodeIgniter大约一个月了。 2)我的代码绝对没有错误!!所以这是一个纯系统错误,而不是语法/运行时错误。
致命错误:类CI_Session_database_driver包含1个抽象方法,因此必须声明为abstract或实现 其余方法(SessionHandlerInterface :: read)中 的 C:\ XAMPP \ htdocs中\ pokopoko \ SYSTEM \库\会话\ DRIVERS \ Session_database_driver.php 在线 49
遇到PHP错误
严重性:错误
消息:类CI_Session_database_driver包含1个抽象方法 因此必须宣布抽象或实施其余的 方法(SessionHandlerInterface :: read)
文件名:drivers / Session_database_driver.php
行号:49
回溯:
错误文字并不总是一样的!有时:
Filename: drivers/Session_files_driver.php
或者
Filename: drivers/Session_database_driver.php
或者
Filename: Session/Session_driver.php
或者
Filename: core/Input.php
甚至
Filename: Unknown
这个错误发生在随机时间,当我重新加载我的网站,或者甚至当我的网站仍然在浏览器中打开(闲置)而我没有做任何事情时,我的ajax突然无法正常工作!这不仅发生在某些浏览器中!我绝对没有更改/修改/打开任何CodeIgniter的系统文件!!
很少有截图:
这是什么?解决方案是什么?帮助我。这是我autoload.php
& config.php
内容:
我的autoload.php
:
$autoload['packages'] = array();
$autoload['libraries'] = array('database','session'); //I set this
$autoload['drivers'] = array();
$autoload['helper'] = array('url','array'); //I set this
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array();
我的config.php
:
$config['base_url'] = 'http://localhost/pokopoko/'; //I set this
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
我试过@Fairy Dancer的解决方案。工作大约1小时,但然后再次出现此错误(错误信息已更改,但仍然相同Session_database_driver.php on line 49
)
昨天@Rahi和我一起怀疑它可能是CodeIgniter 3与PHP> 7之间的错误。还有其他具有相同环境/组合的开发人员遇到此问题,例如:https://forum.codeigniter.com/thread-66544.html。但是我无法降级我的PHP,因为我使用了许多PHP 7新的简称,如??
。如果这是真的,也许我会等到另一个解决方案,或者直到CI有更新版本修复此错误。
答案 0 :(得分:1)
更改会话
$config['sess_driver'] = 'files';
至$config['sess_driver'] = 'database';
并将sql代码执行到数据库表中
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(128) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL, KEY `ci_sessions_timestamp` (`timestamp`));
确保在database.php
文件中配置数据库。
如果这不起作用,请告诉我
答案 1 :(得分:0)
替换
$config['sess_driver'] = 'files';
带
$config['sess_driver'] = 'database';
答案 2 :(得分:0)
当我使用PHP 7.1时遇到同样的问题
但如果我降级到PHP 7.0,错误就会消失......
尝试使用PHP 7.0并且根本不会更改Codeigniter。
答案 3 :(得分:-1)
有时会发生,只是重新启动服务器(无论是apache还是非apache),重新启动服务器后错误都会消失......取决于工作时发生的错误的类型。如果错误是在工作时自动发生的,则只需重启服务器即可将其消除。就我而言,只需停止并启动我的本地xampp服务器,它就会消失。