Navigation:    Home arrow Installing Apache, PHP & MySQL
Installing Apache, PHP, MySQL on a Windows 98/2000/XP Computer PDF  
Digg Reddit Ma.gnolia Stumble Upon Facebook Twitter Google Yahoo! MyWeb Furl" BlinkList Technorati Mixx Bookmark
Article Index
Installing Apache, PHP, MySQL on a Windows 98/2000/XP Computer
Page 2
Page 3
Page 4
 

Step 8. Testing working of PHP with MySQL
Well, this is the last step in configuring your system to work with Apache, PHP and MySQL. For that we we'll write a php code that connect to our MySQL database server, create a database and insert into that database a record. After that our program will display the records from MySQL database.

Here is the program (copy-it into c:\phpwebsite):

<?php
mysql_connect("localhost");

mysql_query("create database testing_database");
mysql_query("use testing_database");
mysql_query("create table my_record(name varchar(60))");
mysql_query("insert into my_record(name) values ('John Doe')");

$sql_query = mysql_query("select * from my_record");
while ($row = mysql_fetch_array($sql_query))
{
print ("Added record: ".$row[name]."<br>");
}
mysql_close();
?>



Run this script. Press refress button from your browser. At every refresh a record containing John Doe name must be inserted into the database. If it does then your configuration is succesfuly.

Of course this is the basic instalation. But is a complete one. In time maybe you will need other things. For example when installing complex script warnings might appear on the screen. Or when trying to upload files from your scripts uploading is not working for files larger than 2mb. In those situations you must modify php.ini from c:\windows or httpd.conf file acordingly, depending of the error. You must find what variable shoud modify and from where (php.ini or httpd.conf).

If you do all steps exactly as in this Tutorial you must have no problems installing Apache, PHP and MySQL.

I wish you good luck with your Instalation!

 

If you found this tutorial useful you might be interested to read the following:

PHP Form image verification
PHP Create Image Thumbnail
PHP Form Image Upload
PHP print random image from a folder
Count Words in a string using PHP