Showing posts with label mysql:php. Show all posts
Showing posts with label mysql:php. Show all posts

Thursday, March 29, 2007

Introduction to Database Driven Development, PHP and MySQL

By Adam Knife
PHP is one of the “scripting languages” of the Web. It is an interpreted language, interpreted by the official PHP interpreter, developed specifically for web programming. Being quite similar to ASP in many ways, chances are a change from ASP to PHP would not be all that difficult for a seasoned developer who was experienced in a C-style language.

PHP, combined with Apache, or another web server handles all the “standard” web serving side of development; it watches for requests, it hands them off to the appropriate handlers, it sends the required headers, and it finalizes the job.

On it’s own, PHP is a language capable of many simple things: date functions, file manipulation, mathematics, logic, all the traditional programming language stuff (including some very feature-filled mechanics for topics such as string manipulation and date manipulation) - but it doesn’t expand in to the power given by database driven web applications. Luckily, there are standard libraries such as the MySQL library, which allow you to easily integrate databases in to your project.

A database is simply that, a collection of data. MySQL is both a relational database server, and query language. It allows users to easily create tables of information, which are sortable by a number of columns, and capable of handling millions of rows of information. Rather impressive when you look at it’s simplicity.

MySQL (pronounced My Sequel) is an implementation of the popular SQL - “structured query language” - don’t worry if you’ve never heard of SQL before - we’ll get there in a later lesson. Information can be stored in a SQL database, and accessed in a range of different ways, manipulated, modified, and stored rapidly.

But wait, why the heck do we want to store our content in a database? Why not just store it in flat files? That’s an easy question. If by flat files, you mean storing it in plain text files and loading it in to a PHP-powered templating system - the database is faster. If by flat files, you mean storing it in HTML files and linking them around, you’ve probably already answered your own question. HTML-only websites are messy, frequently ending up with hundreds of files, each with their own copy of the template, among other things. A simple change for an HTML-only site could take days to implement, where in a PHP-MySQL-powered site it would take minutes.

On top of that, by integrating PHP + MySQL in to your project you open a range of new uses. In the future you could set up a web-service for a software application to contact your database server and get the content, you could sell your database of content, or you could further manipulate the way the content is stored.

The advantages to a database driven, scripting language powered site are numerous, and you shall realize them more and more as you get deeper in to web development.

Adam X. Knife is a professional web developer and author of the new Code Hippo programming "blog"-style site. When he's not writing articles on programming, or developing code himself, he's reviewing laptops or MP3 Players.

Article Source: http://EzineArticles.com/?expert=Adam_Knife

Apache, MySQL & PHP for Windows

By Sanjib Ahmad
Apache, MysQL and PHP for Windows could be a nice nice thing to have on your Windows workstation. You could try and experiment with all kinds of nice PHP and MySQL based applications right on your Windows desktop running Apache, instead of having to access a full-featured server.

Most people have Windows as their workstation and it can be sometimes difficult to switch to another operating system. So, you may have always wanted to run PHP applications on your Windows machine but wondered if it is too difficult to install or if the hassle will be worth it.

This article gives you the essential information to get started right away. Even if you are a seasoned PHP, MySQL and Apache guru, the checklist below will still be helpful in your installation process.

There are lots of 3rd party software that bundles Apache, MySQL & PHP in one package and installs them on our computer. We do not recommend this and suggest that you directly get Apache, MySQL & PHP from their official sites.

Apache

1. Get Apache 1.3.33 from here: http://httpd.apache.org/download.cgi.

2. Choose a mirror close to you and in the same page, look for the Win32 Binary (Self extracting) file: apache_1.3.33-win32-x86-no_src.exe.

3. Download the file and save it on your hard disk. Run the installer and the self- extracting wizard will guide you through the rest of the steps. Choose all the default settings and run Apache as a service.

4. Remember to put "localhost" when asked for a Server name/Domain name. Use "administrator@localhost" when asked for the administrative email account.

5. Now point your browser to: http://localhost and you should see an Apache Test Page.

6. You can change this page by creating an "index.html" page here "C:Program FilesApache GroupApachehtdocs".

7. You can manually start and stop the Apache server. In a Windows command prompt, type "net stop apache" or "net start apache".

MySQL

1. Get MySQL 4.1.7 from here: http://dev.mysql.com/downloads/mysql/4.1.html

2. Under the Windows downloads section, choose Windows Essentials (x86) and click on the Pick a Mirror link.

3. Download the file mysql-4.1.7-essential-win.msi and save it on your hard disk. Run the installer and the self-extracting wizard will guide you through the rest of the steps. Remember the root password when prompted for it in the installation process.

4. Once the installation is done, on your Windows toolbar, go to "Start->Programs- >MySQL->MySQL Server 4.1->MySQL Command Line Client".

5. Type the root password and you should be logged in to the MySQL shell.

6. Type "show databases;" to see the list of databases. Type "quit" when you are done.

PHP

1. Get PHP 4.3.10 from here: http://www.php.net/downloads.php

2. Under the Windows Binaries section, choose the file: PHP 4.3.10 zip package size 7,405Kb dated 15 Dec 2004.

3. Download the file and save it on your hard disk. Unzip the file and rename the extracted folder to "php". Now move this folder "php" and place it under "C: Program Files".

4. Move all the files under "C:Program Filesphpdlls" and "C:Program Filesphpsapi" to here: "C:Program Filesphp".

5. Copy the file php.ini-recommended to "C:WINDOWS" and rename it to php.ini

6. Edit your Apache "httpd.conf" configuration file located here: "C:Program FilesApache GroupApacheconf".

7. Add the following lines in httpd.conf:

LoadModule php4_module "C:/Program Files/php/php4apache.dll"
AddModule mod_php4.c
AddType application/x-httpd-php .php

8. Now stop your server by issuing the following command in Windows command prompt: "net stop apache". Then type "net start apache" to start your server. We are now going to test the PHP installation.

9. Go to "C:Program FilesApache GroupApachehtdocs" and create a file test.php

10. Edit test.php and add the following code:

<? php phpinfo(); ?>

11. Point your browser to http://localhost/test.php and you should see a lot of PHP configuration information.

Congratulations! You now have Apache, MySQL and PHP installed in your computer. Now you can install your favorite script right on your Windows workstation.

Sanjib Ahmad, Freelance Writer and Product Consultant for Business.Marc8.com - Business Best Sellers.

You are free to use this article in its entirety as long as you leave all links in place, do not modify the content, and include the resource box listed above.

Article Source: http://EzineArticles.com/?expert=Sanjib_Ahmad