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 trial
aduratomi okiji
2,561 PointsMySql Database with php
Hi, I am currently taking "using php with mysql" course and i am having trouble making the PDO object in XAMP. my code is as the following. ' $db = new PDO("mysql:host=localhost;dbname=shrits4mike;port=3306","root","root");'. Everything for the database is on its default setting. Please provide an asnwer to my question. Every time I run this code it give man exception.
2 Answers
Ben Rubin
Courses Plus Student 14,658 PointsIf you're using the default setup with xampp, your database probably doesn't have a password, so using "root" as the password is what's causing the problem. Also, make sure your spelling of "shirts4mike is correct. The "i" and the "r" are swapped in the code that you listed. Try this:
$db = new PDO("mysql:host=localhost;dbname=shirts4mike;port=3306","root","");
aduratomi okiji
2,561 PointsIT WORKS!Thank you so much!!!