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


Christhoper Key
Christhoper Key
Courses Plus Student 2,061 Points

Connection to database

Hello! As i manage to complete "PHP besic" i would like to connect my localhost with database and play around with some codes.

My question: is there "best" or "most" secure way to build connect with database?

1 Answer

When it comes to coding, database, and server access, yes there's always "best practices". The best approach to connect to your database is to use PHP mysqli or PDO method. How you use those methods to access or allow others to access your database can be the deciding factor.

1 - you're likely to have your environment set up as:

$user = root;
$password = root;

...that's not best practice.

Refer to this link for some good tips

Hope this helps!