Changes

Jump to: navigation, search

Using PHP with MySQL

16 bytes removed, 20:15, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0"> " to "<table border="0" cellspacing="0" width="100%">"
<table border="0" cellspacing="0" width="100%"><tr>
<td width="20%">[[PHP Object Oriented Programming|Previous]]<td align="center">[[PHP Essentials|Table of Contents]]<td width="20%" align="right">[[PHP and SQLite|Next]]</td>
<tr>
<googlehtmlet>BUY_PHPphp</googlehtmlet>
== Connecting with PHP to a MySQL Server ==
<googlehtmlet>ADSDAQBOX_FLOWadsdaqbox_flow</googlehtmlet>
Now that we have set up our MySQL database and entered some data it is time to look at using PHP to connect to the database so that we can start to query the database and add new data. The first step in our PHP script is to connect to our MySQL database server. This is achieved using the PHP ''mysql_connect()'' function. The ''mysql_connect()'' function creates a connection to the database server and returns a database resource handle. The function takes five optional arguments. The first is the address of the server hosting the database. This defaults to ''localhost:3306''. The second argument is the user name to be used to connect to the database. The third argument is the password associated with the user name.
Probably one of the most powerful features of PHP (next to ease of use) is the ease with which it is possible to access and manipulate MySQL databases from PHP scripts. Without database access many web sites would simply cease to function. Without the built in support for MySQL the task of developing database powered web applications would be formidable task. As we have demonstrated in this chapter, PHP makes MySQL database access fast and easy. PHP essentially does all the work of communicating with the database server for us. All we need to do is write the SQL commands to pass to MySQL and PHP does the rest.
<googlehtmlet>BUY_PHP_BOTTOMphp</googlehtmlet>

Navigation menu