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 trialNaomi Freeman
Treehouse Guest TeacherConnect to live database
Hi guys!
I'm playing with PHP and am working through the "Using PHP with MySQL" course.
Just want to confirm this
$db = new PDO("mysql:host=localhost;dbname=shirts4mike;port=8889","root","root");
in live, for a hosted phpMyAdmin database would be
$db = new PDO("mysql:host="http://www.register365.com";dbname=maps;","username_for_register365","password_for_365");
The register365 site is where the phpMyAdmin is hosted. register365 seems to be down at the moment so I can't test it and I want to make sure I'm on the right track when the site comes back up.
Thanks!
2 Answers
Kevin Korte
28,149 PointsI don't think you have access to DNS servers at this level in your code, meaning your host would be the IP address of the server that has the database you want to connect to. If the server also is running mqsql database, you should be able to use localhost in production, because the production database would be local to the production server.
Naomi Freeman
Treehouse Guest TeacherThanks! Now I'm just trying to figure out where that IP address is lol The admin seems very stripped back. I'm so used to working in a super large environment where I just product code and the rest kind of is managed by wizards.
Cheers,