2

So I'm running this tutorial series that helps you create a light social networking site using Laravel, Gulp and Codeception.

I'm at the part where we build the registration form. The layout is done, code is done, user table added.

When I goto the register page and fill in the form and hit submit, I get this error

SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected (SQL: insert into `users` (`username`, `email`, `password`, `updated_at`, `created_at`) values (sad, s@s.com, s, 2015-03-29 05:32:18, 2015-03-29 05:32:18))

I am using getenv() in database.php

'mysql' => array(
            'driver'    => 'mysql',
            // 'host'      => 'localhost',
            // 'database'  => 'forge',
            // 'username'  => 'forge',
            // 'password'  => '',
            'host'      => getenv("DB_HOST"),
            'database'  => getenv("DB_NAME"),
            'username'  => getenv("DB_USERNAME"),
            'password'  => getenv("DB_PASSWORD"),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

I have database.php in 2 places: /app/config/local/database.php and /app/config/database.php

And this is .env.local.php and .env.testing.php both in the root director

 return array(
        'DB_HOST' => 'localhost',
        'DB_USERNAME' => 'root',
        'DB_PASSWORD' => '',
        'DB_NAME' => 'larabook'
    );

And this is in /bootstrap/start.php

$env = $app->detectEnvironment(array(

    'localhost' => array('localhost'),

));
Halnex
  • 4,242
  • 12
  • 49
  • 102

1 Answers1

0

Silly me, I had to set my machine name in start.php

'local' => array('your-machine-name'),

That fixed the problem.

Halnex
  • 4,242
  • 12
  • 49
  • 102