Installing Apache 2.0 Web Server, PHP 4.2.0, Mysql 3.23, and Phpmyadmin On Windows For Use With Flash
Installing Apache 2.0 Web Server, PHP 4.2.0, Mysql 3.23, and Phpmyadmin On Windows For Use With Flash
Introduction
This article attempts to detail the installation of the Apache 2.0 web server, the PHP version 4.2.0
scripting language, the latest MySQL DBMS, and PHPMyAdmin on a windows (98, ME, XP, etc)
desktop. Although their are a couple of tools that will do the installation of all these for you - the
knowledge gained from setting these items up yourself far outweighs the any time saved with the
auto-install programs.
Because Mac OS X - comes with most of these tools already installed ( read this article for more of
the same but on a Mac), as well as almost all Linux distributions, and most versions of Unix we will
not be discussing those OS's in this article, however since these tools work basically the same in
any environment you may still find something useful here.
With all of Flash/PHP applications and tutorials available on the internet and books one item that
many people have trouble with is working with those scripts on their local computer. That being
the case this article is meant as a guide for Flash designers and programmers on how to set up a
complete development platform for use with dynamic server-side flash site's on your home, work,
or whatever computer you happen to be working on at the time. Examples and small exercise's on
how to configure and use the above tools are also documented. Also a small example of a
Flash/PHP/MySQL app. Not to many articles/tutorials go over how to setup/install/use your own
web server, database, and scripting language - so parts of this can become somewhat technical - but
stick with it and you'll get it all working together.
This combination allows you to turn your home computer into a server that anyone with your IP
address will be able to view just as if it was any other website on the internet (if you allow them) -
the advantage being that you are the systems administer, and will not have to FTP anywhere to
upload files. Meaning it's a whole lot easier to test things out without having to upload your files to
a different server every time you want to test out your dynamic flash movie. Installing all these
tools on your home computer gives you a real insight on how the rest of the internet works - that
and if you ever have a problem with one of the techie's that run your current hosting company,
you'll be able to give a much more detailed description of why they have no idea what their talking
about (or how much you appreciate them!).
Note: This is an unofficial reference. It's meant only as a guide to help you get started exploring
this area on your home computer. The topics cover only the very tip of the iceberg of what is
possible with these tools. For any serious development where security, stability, and power is an
issue consult a professional and have them set things up for you, and please don't use windows.
Most of the time Shared hosting companies or companies that offer dedicated servers can provide
you with this on the Unix platform of your choice.
Note: For those of you that have little experience in this area, things can get frustrating and
complicated fairly fast when first starting out. Sometimes it can be difficult to use configuration
files instead of a user interface, and while their are user interface's available for these tools - it's
much more sensible to use the config file instead to gain a better understanding of what's going on.
As a side note: because the configuration files are basically text based files, it's possible to create
your own interface for these tools. I would love to see someone create a Flash version of
PHPMyAdmin, it's possible, but would take some serious time.
1
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
Note: These programs/tools, much like most internet protocols and standards, where created for a
Unix environment and only ported over to windows. Even out of their native environment the do
seem to work exceptionally well in this case, however.
If your having problems ask questions either on the Flashkit.com scripting and backend message
board - or on the message board at Flash-db.com and someone will have an answer for you right
away.
Overview
We'll go over the details of each installation in the order below on the following pages.
Apache 2.0 Web Server: The Apache web server is used on more websites then all other web
servers combined. And is the basis for many others. The new 2.0 version has new improvements
for a windows environment making it run equally as well on any version of windows as it does on
Unix, BeOS, OS/2 etc.
PHP 4.2.0: PHP is one of the many server side scripting languages that allow you to interact with
the server (such as writing text files, inserting info into a database, sending email, etc). One of the
greatest advantages of PHP is that it can be used equally as well on any OS/server combination.
The PHP scripting language has evolved and continues to evolve every day through contributions
and work by thousands upon thousands of developers world-wide. This continual evolution process
makes PHP one of, if not the most, powerful and feature rich server side scripting language
available to any developer. At the time of writing PHP 4.2.0 is the latest release of this
evolutionary process.
MySQL: MySQL is a database management system. MySQL is one of the most popular SQL
database server's. In recent benchmarks it's faster then similar DBMS's such as Oracle and MS
SQL (for web based querying) - but does lack some of the User Interface features of those
systems. In this article we will be installing MySQL version 3.23. However you may want to
download the newer MySQL 4.0 (Installation should be about the same). MySQL 4.0 includes new
features such as Transaction support, the Union Statement, and will soon include greater Foreign
key rules. While most of us will never use these new features they are important when you start
getting into more advanced applications.
PHPMyAdmin: PHPMyAdim allows you to easily manage your MySQL database from any
browser. While their are quite a few other web based tools that allow you to easily work with
MySQL this is one of the easiest and widely used. More and more hosting companies are including
this feature for you to use in conjunction with your site you have hosted on their servers. Having
this installed on your local machine makes transferring, backing up, working with, and creating
your database much easier then having to use the command line. This is basically a User Interface
for MySQL that you can use from a web browser such as Internet explorer or Netscape.
2
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
The first thing we need to do is download the Apache installation program. We are going to be
using the automated version (windows installer MSI) - you can also download the source files but
that gets a little complicated.
2) This will start to run through some setup options. When you get to a screen that asks for some
Server Information. Use "localhost" for the Network Domain and Server Name (you can change
this later). Then enter your email address in the Administrator's Email field.
4) On the next screen select the default Destination Folder - this will be 'C:\Program Files\Apache
Group\' you can choose a different folder if needed but we will be working with this one.
5) After this the setup should be complete - Hit the install button and you'll get a success message
when it's complete. Click finish.
6) A couple of options should have been added to your start menu. Find the Apache option on the
Start menu and then the 'Control Apache' Submenu. Press the Start option from that submenu.
The apache services monitor should also have been added. With this you can easily start, stop, and
restart the Apache Web server.
Then open up a web browser and type in the address: http://localhost/ You should see a default
Apache page appear in your web browser. It easiest if you create a shortcut to this URL on your
desktop for future use. (In the off chance that you have a different web server running such as PWS
or IIS running on your computer - make sure to stop that service before starting apache).
Since we want to display are own page instead of the default page - find your way to the htdocs
folder located at: C:\Program Files\Apache Group\Apache2\htdocs folder. You can just delete
all of the default index.html.lang files and all the other files in this directory and replace this with
your own index.html page you want to display as the default. Personally I like to make this my
startup page and just have a bunch of links to either Projects in different folders I'm working on or
to sites on the internet that I often visit. The htdocs folder is your main web directory - you can use
this just as if you where uploading files to a server somewhere else. It sometimes makes things
easier if you place a shortcut to this folder on your desktop as well.
Are next task will to become familiar with the httpd.conf file (Located: C:\Program Files\Apache
Group\Apache2\conf\httpd.conf). This contains a set of directives and configuration settings for
your server. For the most part you will not have to change this much when just using apache for
testing/development. It is however a good idea to become familiar with this file and look it over.
So open it up with Notepad and have a look.
Exercise: Changing the default directory page. Normally the default directory page is
index.html. As an intro to using the httpd.conf file where going to change the default page apache
serves when a directory is requested to something else.
Change this to DirectoryIndex MyNewIndex.html Now whenever you request a specific directory -
this will be the page Apache will first look for. You can add additional default pages to that and
Apache will look for those pages in that order, personally I like to change this to DirectoryIndex
index.php index.html index.htm. (This is usually never needed - although it's nice to know how to
do).
Exercise: Using .htaccess files. .htaccess files are like small parts of the web server configuration.
You can place these file's in specific directory's to override the settings in the main httpd.conf file
and to add special access controls and functionality to that directory. .htaccess files are valid for all
folders that are contained within the you've placed it in. To allow the use of .htaccess files we do
however have to change one part of the httpd.conf file. Open up that file with Notepad now and
change the following line: (search httpd.conf for 'AllowOverride' to find the line faster).
AllowOverride None To AllowOverride All (This allows us to use .htaccess files in any
directory).
Example 1: Creating directory specific DirectoryIndex files. Use notepad or a similar text editor
to create a file called .htaccess and place that file in a directory/folder you want this to be valid for.
Inside this file place the following;
DirectoryIndex MyMainPage.html
This will make it so that if you visit this directory (folder) such as http://localhost/MyFolder/ - the
default start page will be MyMainPage.html.
Example 2: Creating Custom error pages within a specific directory. Follow the above steps to
create a .htaccess file and add the following to that file;
This just creates custom error documents and tells the server what to do and where to go if it finds
an error such as your page not being found. You can also specify default error pages in the main
httpd.conf settings. However those settings will be valid throughout your site and not just in one
directory.
4
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
Example 3: Creating a password protected Directory. This gets a little tricky. But is one of the
most useful examples of the .htaccess file for our purpose's. Create an .htaccess file as before with
the following and place it inside any directory you want to password protect.
require valid-user
You will also need to create a file that contains a UserName and a Password. This file will be
called (for this example) users (with no file extension) and placed in a folder we just created called
Passwords at C:\Passwords\. Their are two basic ways you can create the UserName and encrypted
password 1 way is using the PHP crypt() function, the second is using the htpasswd program that
comes with Apache. We will be using the second method.
To create this file you'll have to open a Dos prompt and CD (Change directory) to CD C:\Program
Files\Apache Group\Apache2\Bin\ Then run the following command:
htpasswd -bc users Jeff mypass (the format is -bc NameToCallFile UserName Password). This
will create a file called users in the Bin directory. The contents will look similiar to:
Jeff:$apr1$aq2.....$OtFywTSs9g9dBsnFlTRTj/ (The first part is the userName the second part after
the colon is the encrypted password). Copy and paste this file into the C:\Passwords\ folder we
created just a bit ago.
When you try to access the Folder/Directory you placed this .htaccess file in with a web browser
you will be prompted to enter a UserName and Password. Enter in the UserName and password
you used to create the file and you'll be allowed in.
Overall it's not that important or secure to use this type of directory protection on Windows (cause
it's still windows after all) and where mainly going to be using this as a local testing area. If you
allow access to your server by others from all over the internet it will still help in keeping specified
directory's contents private and with controlled access.
That's about it for the Apache installation. By locating your IP address that your computer is
currently using for it's connection to the internet, you'll be able to give that address to others so they
can view your website running on your own personal computer. Since most ISP's such as cable and
DSL providers change your IP address all the time you'll either have to keep telling others what
your new IP is - or sign up for a service which constantly updates each time your IP changes and
points it to a specific domain name for you. If you are planning on letting other's visit your website
running on a server on your home computer it's also a good idea to keep your firewall going - you'll
have to change some settings so that it allows others to view your site.
5
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
First we have to download PHP 4.2.0, You can do so at the following link:
http://www.php.net/downloads.php (PHP 4.2.0 zip package).
Or more specifically here: PHP 4.2.0 zip package
The installation file that comes with PHP 4.2.0 does not come with instructions on how to configure
with Apache 2.0 but is still a useful reference. Also for everything you ever need to know, want to
know, and more then you can ever know about PHP read over the documentation at
http://www.php.net/manual/en/.
1) After you have downloaded the zip file. Unzip all of these files to the C:\ directory. This will
create a directory structure like: C:\php-4.2.0-Win32. Rename this folder to C:\PHP
3) Rename this file (php.ini-recommended) to php.ini once you have placed it within the
windows folder. You can rename the file with Notepad. Since the php.ini file is often used I like to
place a shortcut to it on my desktop.
4) Copy the file C:\PHP\php4ts.dll file to your windows system folder: c:\winnt\system32 or
c:\windows\system (for XP and ME it's the windows\system folder).
We now need to edit both the PHP.ini file and the Apache httpd.conf file.
Open up the httpd.conf file that we where working with when we first installed Apache with
Notepad. Look for a block of LoadModule commands (this is located near the beginning of this
file). Then insert the following line right after all the the other LoadModule commands:
Please note that you must use the apache2filter.dll and not the php4apache.dll. With earlier
versions of PHP (before 4.2.0 and Apache 2.0 you do however use the php4apache.dll). This is an
important change to keep in mind when using earlier versions of Apache with PHP.
We have to add one last item to the httpd.conf file before where done with it.
Add the following Line to your httpd.conf file (somewhere after the LoadModule command we
just added);
For now all we have to add is the 'doc_root' path (Search the file for doc_root to find it faster). Add
the path to the htdocs folder. This path will be something like: C:\Program Files\Apache
Group\Apache2\htdocs so that the line now looks like:
6
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
That should be it. At least it should be enough so that PHP will be running in conjunction with the
Apache web server. To test this try the following.
<?
phpinfo();
?>
Then add this file to your htdocs folder. Open up a browser and type in the following URL:
http://localhost/PHPInfo.php If everything went successfully you'll see a long list of all your PHP
settings and server information. When starting Apache you should also see a small note that the
PHP 4.2.0 module has loaded, also when your viewing the 'Apache Service Monitor' you should see
a small note at the bottom indicating that PHP 4.2.0 is running.
On the next page we'll go into some exercise's and fun stuff to do with PHP and Apache.
7
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
The SMTP setting 'mail.yourISP.com' should be the same outgoing SMTP setting you have
specified in Outlook. As long as you can send and recieve email from Outlook and have the
username and password set in Outlook, you'll be able to do the same with PHP. (Remember to
Restart Apache after you have made the change to the PHP.ini file!).
You test this by creating a file called: EmailTest.php and placing this in your htdocs folder. Add
the following to this file:
<?php
$FromName = "Jeff Hill";
$FromEmail = "[email protected]";
$ToName = "Someone";
$ToEmail = "[email protected]";
$ToSubject = "Testing Email from my Computer";
$Message="This is a test - hopefully I get this email";
Then run this by opening up a browser window to the URL: http://localhost/EmailTest.php. If you
want to create a flash movie that allows you to send email. Remove the first 6 lines from this script
- then create a flash movie with corresponding Input text boxes with the same variable names - such
as FromName, ToEmail, Message etc. Then make a button with the following actionscript on it:
loadvariablesNum("EmailTest.php", 0, "POST"); this will send the variables a user enters to the
modified script and send the email. (This is a very very basic method - but hopefully you get the
idea). Make sure that the swf is in the same directory as EmailTest.php. Also note that you can not
use the "POST" method from within the Flash editing tool ie "Test Movie" (you can use GET
8
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
however) - so you'll have to run this in a SWF in a browser, ie http://localhost/Email.swf. For more
information on creating an Flash Email client - check here.
Open up the PHP.ini file again (see how much the shortcut on your desktop helps). Then find an
area marked by ;Windows Extensions followed immediately by a long list of items that look like:
;extension=******.dll. For this example where going to install the Ming Extension and the GD
Extension.
Remove the semi-colon ; from the beginning of these two extensions (ie ;extension=php_ming.dll
to extension=php_ming.dll). Save the PHP.ini file and restart Apache. Now your able to use all of
the Ming Functions as well as all of the GD functions. (Ming is a set of tools that allow you to
create SWF movies on the fly with Code) (the GD library is a set of functions that allows you to
create and manipulate images with code).
Exercise: Parsing .html (and other file types) as PHP - with Apache and .htaccess files.
(This is optional like all the other exercise's). You can add a couple lines to either the main Apache
httpd.conf file or to .htaccess files in specific directories to parse certain file types as PHP. This is
useful if you don't want to others to know what type of scripting language your using. With the
following line of code you can parse .html files for PHP code - meaning that files ending with .html
can be used in the same way as files ending with .php.
Add this line of code to either the Apache httpd.conf file or to a .htaccess file in a specific directory:
AddType application/x-httpd-php .html
Where not limited to being able to do this with just .html type files. You can do this with basically
any type of file. For example if we wanted someone to think that we where using ASP instead of
PHP we could add this line:
AddType application/x-httpd-php .asp
This would allow you to parse all .asp type file's as PHP (obviosly they have to contain PHP code
however and not ASP code).
Try to have fun with it! I like to make up my own File Extensions such as .Jeff
AddType application/x-httpd-php .Jeff
Now I I can create files like Testing.Jeff - Put some PHP code in their and open up
http://localhost/Testing.Jeff And that file will be parsed as PHP. With your own file extensions
parsed as PHP on your site - anyone taking a look at your site will be like what the heck is going on
here.. (If you really don't want people to know what your using change this line in the PHP.ini file
expose_php = On to expose_php = Off). Some really large sites will do this to avoid giving a
potential hacker even the slightest clue as to what Scripting language their using.
9
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
After you have downloaded this file unzip it to a temporary directory. For exampe:
C:\MySQLTemp
Go to that folder and click the Setup Application file (shown as a computer icon).
The Setup should begin. Click through the first couple of screens and select the default location to
install MySQL to (C:\MySQL).
Next: Open up the file C:\mysql\bin\winmysqladmin.exe (The icon has a little my SQL graphic).
This will prompt you for a UserName and password you want to use for accessing MySQL. Enter a
Username and password of your choice and then click ok. This creates a file called my.ini
(Located: C:\Windows\my.ini) You can open this up if you want, you should see the Username
and Password you just specified as the 3rd and 4th line in this file. Their are some other items you
can change here, but for are purpose's that's all that's needed.
<?php
mysql_connect("localhost","yourUserName","yourPassword") or die("Uh Oh, Could not connect");
$Version = mysql_get_server_info();
$HostInfo = mysql_get_host_info();
print "My current MySQL version is: $Version
On $HostInfo";
?>
Make sure to replace "yourUserName" and "yourPassword" with the ones you choose above. Then
place this file into your htdocs folder and open up: http://localhost/TestSQL.php - This should result
in 2 lines being printed to the screen - saying something like "My current MySQL version is:
3.23.49 On localhost via TCP/IP". If that was successful then MySQL is up and running. You
should also see a Stop Light Icon on your task bar - The light will be Green if mySQL is
running. You can use that to display some system info (select show me) if wanted.
That's about it for MySQL. The next section will go into detail on one Web based tool that easily
allows you to create new database, tables, and the over all structure of your database along with
some simple examples. For those of you that are more comfortable with the command line MySQL
can also be used by opening up a DOS prompt to the C:\mysql\bin directory and typing in MySQL -
then you can go on to do whatever you want with MySQL. This is virtually the same as using
Telnet to access MySQL on a Unix server. However since many of us are not really comfortable
with the Command line option - we'll be using a Tool called PHPMyAdmin that avoids this and
makes MySQL really really easy to use! For further information on MySQL and a great reference
manual visit - http://www.mysql.com/doc/.
10
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
PHPMyAdmin is a web based tool (it's run from a browser) that allows you to easily create,
manipulate, transfer, backup, and manage your MySQL database. PHPMyAdmin runs on a server
and can be used anywhere you have PHP installed. Since we've already installed Apache, MySQL,
and PHP - we've got all the prerequisites covered. PHPMyAdmin can also be used running under
NT/IIS as long as PHP and MySQL are installed.
One of the greatest advantages is that it runs in a web browser, this makes working on sites
remotely easy. More and more web hosting companies are using PHPMyAdmin to allow their
customers to administer their database's (some larger ones include Interland and HostRocket along
with thousands of others). I personally wouldn't recommend a hosting company unless they have
PHPMyAdmin set up. If they've got a version of webmin set up for their users to use - that makes
things even easier.
If your hosting company does not have PHPMyAdmin set up but is running PHP and MySQL
(whether it's a Unix/Linux based or a NT server) in most cases you can install PHPMyAdmin
yourself on this Host (I would ask your technical contact at your hosting company first however).
Having PHPMyAdmin on both your local computer and on the server your using to host your site
on is one of the greatest advantages of all - and makes creating complex database's a relative breeze.
Another advantage of PHPMyAdmin is that it allows you to easily transfer or backup a database
from one server to another (no matter what OS your using).
So let's get on with the Installation and Usage already... well here goes.
Unzip the phpMyAdmin-2.2.6-php.zip file you just downloaded to the directory: C:\Program
Files\Apache Group\Apache2\htdocs\
My Solution: Upload all the files (except the images directory) in the directory you just unzipped to
a different server in ASCII mode. Most/All FTP Clients allow you to choice the mode of file
transfer - either ASCII or Binary, select ASCII in this case. Then download them back to the same
folder. Open any of the PHP files now and check to make sure that they all appear as well formed
11
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
code. You should not do this with the images folder because the images (all images) consist of
Binary data and would be corrupted if you uploaded them in ASCII mode.
Open up the folder you just downloaded the files to. Find a file called config.inc.php in that
directory. Open it up and make these changes:
Add the path to the folder where your PHPMyAdmin files are located in to the
$cfgPmaAbsoluteUri = ''; line. This will look something like: $cfgPmaAbsoluteUri =
'http://localhost/Admin/'; after you've added it. If this was on a real server you would add a
pathname like: http://www.yourserver.com/Admin.
Next add the following: Find the line, $cfgServers[$i]['user'] ='MySQLUserName'; Add the
Username you specified when you set up MySQL - (the one that's located in the my.ini file. Then
add the password to the $cfgServers[$i]['password'] = 'MySQLPass'; line.
You can also leave those two settings Blank. Doing so will result in becoming somewhat of a
superuser or root user. You'll also be able to edit the MySQL user tables in this mode. Normally
you would never want to do this - but since where only using this locally for testing it's not as much
of a concern either way.
12
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
The following exercise's work through creating a table, using PHP to access that table and building
a Flash Client For the User Interface.
First Create a New Database: In the Text field just beneath 'Create a new database' on the main page
enter FlashTest. Then click 'Create'. You should get a message such as 'Database FlashTest has
been created'.
Note: Creating a database will create a Folder in the C:\mysql\data directory. You can check to see
if the folder 'FlashTest' is their - it will be. A database is made up of individual Tables, you can
have as many tables in a database as you want. Each time you create a Table in your database it
will create 3 new files in your C:\mysql\data\FlashTest\ folder. You really don't need to know this
info - but it might be interesting to know where your data is physically being stored - that's where.
Next where going to create a table. On the current screen find where it says "Create new table on
database FlashTest" - then for the Name call it "news". For the amount of Fields enter "4".
On the next screen you'll see something that looks like a table. Fill it out as following by selecting
items from the drop down menu, or typing them into the fields - only the columns that where using
where included:
That's all you'll need for our first table. After you've entered that click 'Save'. After that you should
come to a new screen and the message "table News has been created" should be up top. You've just
created your first table with PHPMyAdmin!
Other items you can now do with your database: First of all try to explore all of the options in
PHPMyAdmin. You can't really hurt anything at this point so just try everything. When your
looking at a new table you can click on 'Properties' which allows to change some of the Fields and
Type's around. You can also click on Insert - where you can manually enter new records if needed.
One Important part is a bit further down that page where it says something like "View dump
(schema) of database" - using the options below that you can create a backup of your database. If
you dump the Structure of the database this will create some SQL (instructions) in formatted text -
this SQL can be used to replicate/backup your database on any computer by instructing MySQL
how to re-create your database exactly as it was at the old location. For this example is we dumped
the table structure of 'FlashTest it would look something like:
CREATE TABLE news (
ID int(11) NOT NULL auto_increment,
UserName varchar(30) NOT NULL default '',
News text NOT NULL,
TimeAdd date NOT NULL default '0000-00-00',
PRIMARY KEY (ID))
13
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
Now what can we do with this table. Well first where going to write two scripts and a small flash
movie so that we can work with this table we just created. The two scripts consist of your 'Middle
Layer' that act as a messenger between your flash client and the MySQL database you have just
created.
Building the Flash Client: (All example files come with the download). Since this tutorial has
already taken a while - the Actual Flash client was included in the download and will not be
covered here in great detail. The main parts to it consist of 1 text area called: News. Where you
News will be loaded to from the database. And two other text fields called 'UserName' and
'EnterNews'. Their is also one button. What this will do is just a small example of selecting and
inserting data from/into a MySQL database. On the 'Add News' button their is the following
Actionscript: loadVariablesNum("AddNews.php","0","POST"); This handles adding/inserting a
new record into the database. Their is also one frame action that loads the current news from the
database: loadVariablesNum("SelectNews.php","0");
You should be able to add the 'FlashExample' folder (in the download) to your htdocs web root
folder and have everything working right away - as long as the above steps in creating your
database and table where followed above.
The AddNews.php script contained in the download will take a User Entered Name and a news
Item and add it to your newly formed table (news) in the Database (FlashTest) - when the 'Add
News' button is pressed.
The SelectNews.php script will Select all of the news Items currently in the table (news) in the
database (FlashTest) we just created and display them in your Flash movie.
Their is also a refresh button on the Flash client that will allow you to refresh the News area after
you've added a new entry.
And I think that's about it. Hopefully that small sample is at least something you can follow along
with the Code in the scripts and Flash movie.
14
Installing Apache 2.0 web server, PHP 4.2.0, MySQL 3.23, and PHPMyAdmin on windows for use with Flash.
Conclusion
Hopefully this article was somewhat informative. I'll try to keep this updated as emails and
questions arise (here). One thing to remember is that their are installation programs available that
allow you to automatically install all of these tools at one time - this is a good thing, but doing it the
long way as described in this article will give you more knowledge on how things are really set up
and allow you to advance at a much faster rate in the long run. And I think that's about it.
-Jeffrey F. Hill
Questions: Flash-db Board
http://www.flash-db.com
» Download
Download the files used in this tutorial.
Download (30 kb)
Get conversion and unzipping tools for PC and Mac here!
15