Home > Articles > Data > Access

  • Print
  • + Share This
Like this article? We recommend

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:

$db = mysql_connect("localhost", "");
$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"));

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.

  • + Share This
  • 🔖 Save To Your Account