Home arrow MySQL arrow Page 2 - Getting PHP to Talk to MySQL

Querying the Database with PHP Functions - MySQL

In this first part of a three-part series. you will begin learning how to use PHP to display and modify data from a MySQL database. This article is excerpted from chapter 9 of Learning PHP and MySQL, written by Michele Davis and Jon Phillips (O'Reilly, 2006; ISBN: 0596101104). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

TABLE OF CONTENTS:
  1. Getting PHP to Talk to MySQL
  2. Querying the Database with PHP Functions
  3. Including Database Login Details
  4. Connecting to the Database
By: O'Reilly Media
Rating: starstarstarstarstar / 8
May 17, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

In this section, we introduce how to connect to a MySQL database with PHP. It's quite simple, and we'll begin shortly with examples, but we should talk briefly about what actually happens. When you try connecting to a MySQL database, the MySQL server authenticates you based on your username and password. PHP handles connecting to the database for you and allows you to immediately start performing queries and gathering data.

As in Chapter 8, we'll need the same pieces of information to connect to the database:

  1. The IP address of the database server
  2. The name of the database
  3. The username
  4. The password

If you're not sure what to use for these values, consult Chapter 7. And, before moving on, make sure you can log into your database using the mysql command-line client.

Figure 9-1 shows how the steps of the database interaction relate to the two types of resources. Building the SELECT statement happens before the third function call but is not shown. It's done with plain PHP code, not a MySQL-specific PHP function.



 
 
>>> More MySQL Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...
- Building a PHP ORM: Deploying a Blog
- TROSYS Launches Free MySQL Manager and Admin...
- Building an ORM in PHP: Domain Modeling
- Building an ORM in PHP
- MySQL Leads Open Source Market, Gets Cluster...
- Oracle Announces Milestone Release for MySQL
- How to Stop SQL Injection Attacks
- New Defragmentation Solution for SQL Server
- Comparison of MyISAM and InnoDB MySQL Databa...


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap

Dev Shed Tutorial Topics: