Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Switched from XAMPP to AMMPS - Uncaught exception 'PDOException' with message 'invalid data source'
  • Hi,

    I have switched from XAMPP stack to AMMPS stack on my development machines. I am having problem running FuelPHP on AMMPS. The problem seems to be with database connection... The error I get is:


    Fatal error: Uncaught exception 'PDOException' with message
    'invalid data source name' in
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/pdo/connection.php:89
    Stack
    trace:
    #0
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/pdo/connection.php(89):
    PDO->__construct('', NULL, NULL, Array)
    #1
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/pdo/connection.php(316):
    Fuel\Core\Database_PDO_Connection->connect()
    #2
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/connection.php(488):
    Fuel\Core\Database_PDO_Connection->escape('edcc6c55b666a56...')
    #3
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/query/builder.php(126):
    Fuel\Core\Database_Connection->quote('edcc6c55b666a56...')
    #4
    /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/query/builder/select.php(413):

    Fuel\Core\Database_Query_Builder->_compile_conditions(Object(Fuel\Core\Database_PDO_Connection),
    Array)
    #5 /Users/primozr/Dropbox/www/dewesoftadmin/fuel/cor in /Users/primozr/Dropbox/www/dewesoftadmin/fuel/core/classes/database/pdo/connection.php on line 94

    The db.php config files seems to be ok:

        'default' => array(
            'type'        => 'pdo',
            'connection'  => array(
                'persistent' => false,
            ),
            'identifier'   => '`',
            'table_prefix' => '',
            'charset'      => 'utf8',
            'caching'      => false,
            'profiling'    => true,
        ),

    and development/db.php

        'default' => array(
            'connection'  => array(
                'dsn'        => 'mysql:host=127.0.0.1;dbname=my_db',
                'username'   => 'dbuser',
                'password'   => 'dbpass',
            ),
        ),

  • Check if the php binary in your stack uses the php.ini file you think it uses.

    Several of these stacks have non-standard apache/php setups, causing the wrong ini file being used, with the result that for example the pdo_mysql.so extension is not loaded, causing this error.
  • Hi Harro,

    looks to be ok. PHPInfo says my PDO is loaded:

    PDO
    drivers mysql, sqlite, sqlite2

    pdo_mysql
    PDO Driver for MySQL enabled
    Client API version 5.6.15

    Directive    Local Value    Master Value
    pdo_mysql.default_socket    /Applications/AMPPS/mysql/tmp/mysql.sock    /Applications/AMPPS/mysql/tmp/mysql.sock
  • Ok. So that isn't the problem.

    Your db config looks ok, it's not a rights issue that prevents the config file from being found? I assume the new stack uses a different user to run?
  • Ok the default DB password was different. Have updated this in db config file and the error is gone.
    But the web application is not rendering entirely for some reason, just get the blank container and a code profiler overlay and no error message in log file... but this looks like another issue that has nothing to do with DB.
  • Ok rendering is not working because <?= $var ?> is not outputting anything. Is this a PHP setting somewhere? Replacing this with <?php echo $var ?> works normally ...
  • Cool short_open_tag was Off in php.ini. Turned it on and works ...

Howdy, Stranger!

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

In this Discussion