| | 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. | 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 | | | | 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...>
| | | | 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 | | | Follow me on: | | | | Advertisement | |
No comments:
Post a Comment