- Introduction
- Using MySQL with Java/JDBC
- Testing MySQL with PHP
- Java Servlet/JDBC Access of MySQL Tables
- PHP Access of MySQL Tables
Testing MySQL with PHP
As stated earlier, no configuration changes are needed to make PHP work with MySQL because PHP software includes support for MySQL. We can look at a quick example, though, to confirm that your installation is functioning properly. Put the following script in your Apache web server htdocs subdirectory. Accessing it in a web browser should display the first row from the Books database table:
Data.php <html> <body> <?php $db = mysql_connect("localhost", ""); mysql_select_db("Test",$db); $result = mysql_query("SELECT * FROM Books",$db); printf( "TITLE: %s<br>\n", mysql_result($result,0,"Title")); printf( "CODE: %s<br>\n", mysql_result($result,0,"Price")); ?> </body> </html>
This section is only meant to test your MySQL configuration before getting into more details of accessing databases within your voice applications. Specific examples of accessing a database using PHP will follow in the later section "PHP Access of MySQL Tables." In the next section, you'll create a JDBC servlet to access the Books table you've created.