Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
SQL Problem
  • Im trying to get my fuel app working on ubuntu wamp. But unfortunately it cant connect. With pdo as driver it told me "invalid datasource(dns)". I switched to mysql since its connect normally with mysql_connect. Fuel tells me now Fuel\Core\Database_Exception [ Error ]:
    Warning: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO) in COREPATH/classes/database/mysql/connection.php @ line 96
    Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in COREPATH/classes/database/mysql/connection.php @ line 127
    Warning: mysql_error() expects parameter 1 to be resource, boolean given in COREPATH/classes/database/mysql/connection.php @ line 130
    Warning: mysql_errno() expects parameter 1 to be resource, boolean given in COREPATH/classes/database/mysql/connection.php @ line 130 this is my db.php under config/test/ : return array(
    'default' => array(
    'connection' => array(
    'dsn' => 'mysql:host=localhost;dbname=heimservice_maker',
    'username' => 'root',
    'password' => '4asd8a4sf4a8sf',
    ),
    ),
    ); The FUEL_ENV is on TEST I dont know why it tells me that no id,pw,host,dbname will be given to the driver. Maybe anyone can help me?
  • The MySQL and MySQLi drivers are no PDO drivers, but native drivers. They therefore don't use the dsn, but require seperate fields:
    Fuel::DEVELOPMENT => array(
        'type'   => 'mysqli',
        'connection' => array(
             'hostname'   => 'localhost',
             'database'   => 'DEV_ClientA',
             'username'   => 'webdev',
             'password'   => 'pwdhere',
             'persistent' => FALSE,
        ),
        'table_prefix' => 'dev_',
        'charset'      => 'utf8',
        'caching'      => false,
        'profiling'    => true,
     ),
    
  • What to do if i wanted to use PDO? I always get this error if i try:
    Fuel\Core\Database_Exception [ Error ]: invalid data source name This error message will be solved by making the dsn global that it can be reached anywhere like in here:
    http://www.sitepoint.com/forums/showthread.php?550473-PDO-invalid-data-source-name What do i have to do to get it working?
  • this is what i get when i dump the connection vars:
    array(1) {
    ["persistent"]=>
    bool(false)
    }
    array(4) {
    ["persistent"]=>
    bool(false)
    ["dsn"]=>
    string(0) ""
    ["username"]=>
    NULL
    ["password"]=>
    NULL
    }
    string(0) ""
    NULL
    NULL
    array(1) {
    [3]=>
    int(2)
    } from
    $this->_connection = new \PDO($dsn, $username, $password, $attrs);

    The problem is now, that he doenst use the Fuel::TEST as environment. <VirtualHost *:80>
    ServerName vps.rpg-stars.de
    SetEnv FUEL_ENV TEST
    DocumentRoot "/home/diddlside/sites/vps.rpg-stars.de/public"
    </VirtualHost> is this wrong?
  • The environment setting is "test", in lower case. Like this it will not detect it and use "development" instead. Which might be the reason the wrong config is used to connect to your database.
  • Thank you, that was the cause!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion