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 trialJesse Schoonveld
2,943 PointsHow do i connect with an online database? As opposed to a local one.
So i recently started learning PHP and i have a local MYSQL database wich i can access and use with the PDO function.
But i have an online server i can use wich has access to online MYSQL databases and i would like to make and access those. However i am not sure how i should make this PDO function work. I made something similar to this:
try {
$pdo = new PDO('mysql:shareddb1b.hosting.stackcp.net;dbname=mydatabase', my username, my password);
}
catch (PDOException $e){
die($e->getMessage());
}
I'm probably missing something completely obvious, i've searched alot of the answer and 99% of examples are people using host=localthost