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 PointsWhat is wrong with my code
Hi, I am currently taking the Using PHP with MySQL course and I am having trouble making the PDO object in XAMMP.
My code is as the following:
$db = new PDO("mysql:host=localhost;dbname=shrits4mike;port=3306","root","root");
Everything in the database is on its default setting. Please provide an answer to my question. Every time I run this code it gives me an exception.
1 Answer
Juan Carballo
8,564 PointsHello. Have you tried to connect to your database with an empty password? Some providers doesn't require a password to connect to mysql database. Try with this one: <code>$db = new PDO("mysql:host=localhost;dbname=shrits4mike;port=3306","root","");</code>