0
votes

Problem

I have installed beansbooks and I'm at the last step, but when I go to localhost/install, I get the following error:

A fatal error has occurred: Session_Exception [ 1 ]: Error reading session data.exception 'ErrorException' with message 'mysql_select_db() expects parameter 2 to be resource, boolean given' in /var/www/html/modules/database/classes/kohana/database/mysql.php:105 Stack trace: #0 [internal function]: Kohana_Core::error_handler(2, 'mysql_select_db...', '/var/www/html/m...', 105, Array) #1 /var/www/html/modules/database/classes/kohana/database/mysql.php(105): mysql_select_db('kohana', false) #2 /var/www/html/application/classes/database/mysql.php(75): Kohana_Database_MySQL->_select_db('kohana') #3 /var/www/html/modules/database/classes/kohana/database/mysql.php(430): Database_MySQL->connect() #4 /var/www/html/modules/database/classes/kohana/database.php(478): Kohana_Database_MySQL->escape('5c8da306617b91-...') #5 [internal function]: Kohana_Database->quote('5c8da306617b91-...') #6 /var/www/html/modules/database/classes/kohana/database/query.php(190): array_map(Array, Array) #7 /var/www/html/modules/database/classes/kohana/database/query/builder/select.php(413): Kohana_Database_Query->compile(Object(Database_MySQL)) #8 /var/www/html/modules/database/classes/kohana/database/query.php(228): Kohana_Database_Query_Builder_Select->compile(Object(Database_MySQL))

9 /var/www/html/modules/database/classes/kohana/session/database.php(131):

Kohana_Database_Query->execute(Object(Database_MySQL)) #10 /var/www/html/modules/database/classes/kohana/session/database.php(111): Kohana_Session_Database->_regenerate() #11 /var/www/html/system/classes/kohana/session.php(300): Kohana_Session_Database->_read(NULL) #12 /var/www/html/system/classes/kohana/session.php(125): Kohana_Session->read(NULL) #13 /var/www/html/modules/database/classes/kohana/session/database.php(74): Kohana_Session->__construct(Array, NULL) #14 /var/www/html/system/classes/kohana/session.php(54): Kohana_Session_Database->__construct(Array, NULL) #15 /var/www/html/application/classes/controller/view.php(49): Kohana_Session::instance() #16 /var/www/html/application/classes/controller/exception.php(27): Controller_View->before() #17 [internal function]: Controller_Exception->before() #18 /var/www/html/system/classes/kohana/request/client/internal.php(103): ReflectionMethod->invoke(Object(Controller_Exception)) #19 /var/www/html/system/classes/kohana/request/client.php(64): Kohana_Request_Client_Internal->execute_request(Object(Request)) #20 /var/www/html/system/classes/kohana/request.php(1154): Kohana_Request_Client->execute(Object(Request)) #21 /var/www/html/application/classes/kohana/exception.php(25): Kohana_Request->execute() #22 [internal function]: Kohana_Exception::handler(Object(Session_Exception)) #23 {main} ~ SYSPATH/classes/kohana/session.php [ 325 ]

How do I solve this problem?

System

php5

Ubuntu 14.04

Mysql 5.5

apache2

1

1 Answers

0
votes

You have problems connecting to the database, because the resource is not returned, just error.

You have several options:

  • re-checking the connection data in config
  • switching to PDO database driver
  • fast hack in the library:

in MODPATH\database\classes\Kohana\Database\MySQL.php method connect() before: $this->_select_db($database); you add:

if(!$this->_connection)
  throw new Database_Exception(':error',
            array(':error' => mysql_error()),
            mysql_errno());

NOTE: There is a problem with PDO that does not support automatic discovery of model. But to debug the connection is enough.

Umm, this can be done according to the art, without modifying the modules:

create file: APPPATH\classes\Database\MySQL.php

class Database_MySQL extends Kohana_Database_MySQL{
  protected function _select_db($database) {
    if(!$this->_connection)
      throw new Database_Exception(':error',
            array(':error' => mysql_error()),
            mysql_errno());
    return parent::_select_db($database);
  }
}