Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark Berning
11,326 PointsMisspelled db name still connects successfully on my local machine (not using Workspaces).
and it creates a new blank file with that misspelled name.
Andrew Phythian
19,747 PointsDid you view the result in the console or in the browser? When I viewed it in the console the outcome was precisely as you describe - no error and a file is generated. When I viewed it in the browser as per the video then the result was as intended.
I have no idea why the outcome was different, maybe somebody else can explain it.
3 Answers
Catherine McLoughlin
2,946 PointsYou can also get an exception by messing with something besides the db name. For example, changing the DSN to "sqliteeeeee:".__DIR__."/database.db" causes an exception to be thrown.
Andrew Phythian
19,747 PointsThis does indeed create an exception. However, as pointed out above, if the .db name is misspelt then it just appears to create a blank version of the .db file when viewed in the console.
Joshua Lawson
4,953 PointsI had the same issue. I tried creating a new database with phpmyadmin and I got no error when connecting, but I did get the "unable to retrieve results" error.
Finally I just downloaded the project files and everything worked fine.
Sonya Trachsel
13,674 PointsHas anyone been able to figure out what exactly is the issue? I'm using MAMP. Is there something we need to add to the existing files for it to work?
Thanks!
Johan Rönkkö
28,054 Pointsi solved it by creating a new database, giving it my own name. Then importing the sql-file in phpMyAdmin. The PDO object should look like this "$db = new PDO($dsn, $user, $password);", Where $dsn is "mysql:host=localhost;dbname=myOwnDatabaseName;port=3306;". $user and $password is simply "root". You can see the config for host, port, etc. on MAMP's website.
Johan Rönkkö
28,054 PointsJohan Rönkkö
28,054 PointsThe problem is: "If 'example.db' does not exist, no exception is thrown but the file 'example.db' is created." from http://php.net/manual/en/pdo.construct.php. The thing is, i have a database.db in my folders, but it doesnt seem to appear in my texteditor when opening the folder. I don't know why...