Wednesday, October 17, 2012

About PHP / MySQL: Connect to MySQL from PHP

If you can't see this email, click here

About.com

PHP / MySQL

PHP Basics

MySQL Basics

Advanced Skills



From Angela Bradley, your Guide to PHP / MySQL
Greetings PHP Programmers!
This week we are taking a look at how to connect to your MySQL database from your PHP files. We also look at holding this information in a separate file that all of your other PHP files can access.
Have a great week!

Connect to MySQL from PHP
The first variable (shown as your.hostaddress.com) is the location of your database. Often this is "localhost". The next two variables are your username and password. This is the login you use for your MySQL database.
See More About:  php functions  using php with mysql 

MySQL Connect Files in PHP
Your website can have several PHP pages that all access your MySQL database. One time saving idea is to store your connection code in a separate file, and then include the file where needed. For example, we can use the SQL code below to login to our MySQL database. Let's save this code in a file called datalogin.php.





 


PHP / MySQL Ads
Featured Articles
Programing Glossary
Reader Response
Social Networking with PHP @ About.com
Learn PHP
Learn MySQL
Advanced PHP

 

More from About.com

Plan a Caribbean Vacation
Whether you're planning a romantic escape, a girlfriend getaway, or an active family vacation we've got the resources you need. Read more...>



How to Eat Locally
Eating locally has many benefits, the food is fresher, tastes better, and has less environmental impact. But how can you get started? Read more...>




This newsletter is written by:
Angela Bradley
PHP / MySQL Guide
Email Me | My Blog | My Forum
 
Sign up for more free newsletters on your favorite topics
You are receiving this newsletter because you subscribed to the About.com PHP / MySQL newsletter. If you wish to change your email address or unsubscribe, please click here.

About.com respects your privacy: Our Privacy Policy

Contact Information:
249 West 17th Street
New York, NY, 10011

© 2012 About.com
 


Must Reads
Learn PHP
Using PHP with MySQL
Learn MySQL
Create Email Forms
PHP Login Script
 
Follow me on:
Facebook Twitter

Advertisement

No comments:

Post a Comment