Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

WAMP Up Your Open Source Development on Windows for Free : Page 3

Apache, MySQL, and PHP, three quarters of the LAMP open source platform that includes Linux, have made serious progress in Windows compatibility. This short guide demonstrates how to install this power trio on Windows for a WAMP platform.


advertisement
Testing Time
Now that Apache, MySQL, and PHP are installed and configured, it is time to test your installation. Leave MySQL running. Apache should already be running, and the changes to the httpd.conf file are enough for Apache to know where to go when it receives .php files. Create a simple script to ensure that Apache and PHP are working together. Copy the following PHP test script to your WordPad or Notepad text editor:

<html> <head> <title>PHP_TESTER</title> </head> <body> <?php phpinfo(); ?> </body> </html>

Save this file as phptester.php to the folder C:\apache2\Apache2\htdocs. Open your favorite Web browser and enter http://localhost/phptester.php. If this is working properly, you should see the details of the PHP installation you just performed.



Using PHP to Access MySQL via Apache
Now, connect to the MySQL database using PHP code. Copy the following into your favorite text editor:

<html> <head> <title>PHP_MySQL_Connection</title> </head> <body> <!— start PHP insert and create MySQL connection details as variables —> <?php // database access variables $Server = "localhost"; $Username = "root"; $Pass = "your-password-here"; $DataBaseName = "banking"; // connect PHP to MySQL $Connection = mysql_connect ($Server, $Username, $Pass) or die ("Connection Denied"); // test the connection with a browser if ($Connection) { echo "<h3>Congratulations! You are ready to build dynamic database-driven Web sites</h3>"; } else { echo "<h3>Back to the lab again*****Something went wrong</h3>"; } // closing the connection is considered good form mysql_close ($Connection); // close the php ?> </body> </html>

And that is that. If you made it this far you now have the MySQL database, the Apache Server, and the PHP language working with each other. The Apache, PHP, and MySQL developers certainly have made high-quality products. Good luck with all your coding.



Gregory L. Magnusson is the founder of Cyborg Spiders Web Development. Since experiencing X-Windows with FreeBSD in 1999, he hasn't looked back. In the current horse race of developing Web technologies, Greg is putting his money on PHP.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap