Home arrow PHP arrow Page 10 - The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP

Are PHP and MySQL Working Together? - PHP

The much anticipated update to our original article on getting Apache, MySQL, Mod_SSL, and PHP to work seamlessly with each other is finally here! Ever try to get Apache, Mod_SSL, PHP, and MySQL all working in harmony on the same box? It's a very difficult task, but article author Israel Denis Jr. has come up with detailed instructions for compiling all these and getting them working together seamlessly to make the killer server software system.

  1. The Soothingly Seamless Setup of Apache, SSL, MySQL, and PHP
  2. Assumptions
  3. Prerequisites
  4. How it Works
  5. Game Plan
  6. PHP Installation (*NIX)
  7. Apache
  8. Testing Our Work: Is Apache working?
  9. Is SSL Working?
  10. Are PHP and MySQL Working Together?
  11. Conclusion
By: Israel Denis Jr. and Eugene Otto
Rating: starstarstarstarstar / 41
June 07, 2000

print this article


Now, we can confirm that PHP is working with MySQL by creating a simple script to do some inserting and deleting of data from the "test2" database. Again this is just a simple script to see if it worked. In another article we will talk about PHP scripting to connect to a MySQL database. Remember, we already created the database and a table. We could had done it here, but chose not to. We wanted to double check that root had privileges to create DB and tables. However, PHP provides support for MySQL so we can easily write code to create a testing database and several records.

Remember, we created the "books" table prior to getting to this point. This portion will not work if you skipped prior sections. We created the "test2" database with a "books" table, and inserted a record for a book.

This script basically goes through the table and list all the fields by name. It's very simple.

$dbuser = 'root';

$dbhost = 'localhost';

$dbpass = 'password';

$dbname = 'test2';

$dbtble = 'books';

$mysql_link = mysql_connect($dbhost,$dbuser,$dbpass);

$column = mysql_list_fields($dbname,$dbtble,$mysql_link);

for($i=0; $i< mysql_num_fields($column); $i++ )
print mysql_field_name($column,$i )."<br>";


A more complex example will show you some of the cool features of PHP.
<title>Example 2 -- more details</title>
<body bgcolor="white">

$dbuser = 'root';

$dbhost = 'localhost';

$dbpass = 'password';

$dbname = 'test2';

$dbtable = 'books';

//------ DATABASE CONNECTION --------//
$mysql_link = mysql_connect($dbhost,$dbuser,$dbpass);
$column = mysql_list_fields($dbname,$dbtable,$mysql_link);
$sql = "SELECT * FROM $dbtable";
$result = mysql_db_query($dbname,$sql);
<table bgcolor="black">
<table><!---- Inside Table ---->
while($value = mysql_fetch_array($result))
print "<tr BGCOLOR=YELLOW>";
//This loop goes through the colums and prints
//each value
for($i=0; $i< mysql_num_fields($column); $i++ )
print "<td> $value[$i] </td>";
print "</tr>";
</table><!---- Inside Table ----->


Notice, how you can have both HTML and PHP commands inside the same file, one of the nice things about PHP scripts. Because you begin with "

>>> More PHP Articles          >>> More By Israel Denis Jr. and Eugene Otto

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: