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 trialSai Kiran Dasika
Courses Plus Student 7,278 PointsDriver Error while using PDO on workspaces
Hey guys, I was getting a " could not find driver" error when ever I try to connect to a mysql database through PDO from the workspaces. Does anyone know what must be the problem with the PHP configuration ?
Sai Kiran Dasika
Courses Plus Student 7,278 Pointstry{
$db = new PDO('mysql:host=hostname;dbname=databasename','username','password');
}
catch(Exception $e)
{
echo $e->getMessage();
die();
}
This was the code that I have it always says driver not found
Ted Sumner
Courses Plus Student 17,967 PointsWill you post the rest of your code as well? That code looks correct to me, so are you positive the error is coming from that? Also, I add a string to the echo $e->getMessage() line so it looks like this:
echo e->getMessage() . ' file function';
This makes sure I know where it really came from.
Benjamin Payne
8,142 PointsDriver Not Found usually indicates you are trying to connect using a driver not available in the php.ini settings, but the fact that this is comming from Workspaces is very weird. Your code looks correct though...so I'm not sure what's going on.
Try adding that string to the end of the exception and also post the rest of your code here like Ted suggested. Adding the string won't fix anything but it will tell you for sure where the exception is comming from.
Best, Ben
Ted Sumner
Courses Plus Student 17,967 PointsActually, posting a link to the fork snapshot would be best. It is the camera icon on the upper right side of the Workspace. Then open the link it creates and copy that or right click and copy the path. If you post that we can then go into your code and play with it directly to figure out the problem and post back to you what we find.
Benjamin Payne
8,142 PointsBenjamin Payne
8,142 PointsHey Sai, Can you copy and paste your code into here?