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 trialsaranyamoellers
31,692 PointsFatal error: Class 'PDO' not found in... I can't connect to database?
<?php
$db = new PDO("mysql:host=127.0.0.1;dbname=shirts4mike;port=3306","root","password");
var_dump($db);
2 Answers
haunguyen
14,985 PointsMaybe you need to enable the PDO in you php.ini file? uncomment to enable.
saranyamoellers
31,692 PointsHello, I found php.ini but I'm not sure where to enable it? I didn't see any comment symbol. I did clt+f to look for PDO in php.ini file, and I found a bunch of them. I don't know what to do and I didn't see any comment symbol to uncomment it. Thank you.
haunguyen
14,985 PointsDepends on your server version, find these statements
extension=pdo.so
extension=pdo_mysql.so
OR
extension=pdo.dll
extension=pdo_mysql.dll
and remove the // to uncomment / activate them
Then restart your apache server (xampp or wamp)
saranyamoellers
31,692 PointsI found them , but none of them has any comment. They have ; (semicolon ) in front of them. ;extension=php_pdo.dll
haunguyen
14,985 Pointsyes, delete the semicolon
saranyamoellers
31,692 PointsWe did it, it works! Thank you so much Haunguyen.
haunguyen
14,985 PointsNo problem. Now you know where to go to add/activate/inactivate server modules for php server.