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: 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.
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.
Lets get started installing and configuring..
Installing Apache 2.0
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.
You can it from this list (apache 2.0.35-win32...msi): http://www.apache.org/dist/httpd/binaries/win32/
Or more specifically here: apache_2.0.35-win32-x86-no_ssl.msi
1) Download this file to your desktop then double click on it.
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.
3) Select the 'Typical' installation option on the next screen.
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.
Well go into details of all this on the next page
Apache examples and exercise's
Open up the httpd.conf file (Located: C:\Program Files\Apache Group\Apache2\conf\httpd.conf) with Notepad - then do a search for index.html. (Any line that starts with the # symbol in the configuration file is a Comment). This should bring you to a line of code that looks like this:
DirectoryIndex index.html index.html.var
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).
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;
ErrorDocument 404 http://www.domain.com/404.html
ErrorDocument 401 http://www.domain.com/401.html
ErrorDocument 500 http://www.domain.com/500.html
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.
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.
AuthName "restricted stuff"
AuthType Basic
AuthUserFile C:\Passwords\users
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.
Next it's onto PHP..
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
2) Copy the file C:\PHP\php.ini-recommended file to your windows folder: c:\winnt or c:\windows.
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:
LoadModule php4_module c:/PHP/experimental/apache2filter.dll (Make sure to use forward slashes for this path instead of Back Slashes).
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);
AddType application/x-httpd-php .php
Next Edit the PHP.ini File.
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:
doc_root = C:\Program Files\Apache Group\Apache2\htdocs
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.
Create a file named PHPInfo.php. Include the following in that file:
<?
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.
Exercise's and Fun configuring PHP
This will work depending on if your ISP does not specifically restrict it. Open up the PHP.ini (c:\windows\PHP.ini) file and find the following lines that look like this:
; For Win32 only.
SMTP = localhost
; For Win32 only.
sendmail_from = me@localhost.com
Change this to:
; For Win32 only.
SMTP = mail.yourISP.com
; For Win32 only.
sendmail_from = YourName@YourSite.com
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 = "Jeff@Flash-db.com";
$ToName = "Someone";
$ToEmail = "SomeTest@someemail.com";
$ToSubject = "Testing Email from my Computer";
$Message="This is a test - hopefully I get this email";
mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FromName." <".$FromEmail.">");
print "Success, the Email has been sent to $ToEmail, they should be receiving it shortly.";
?>
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 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.
Along with everything else that PHP can do - their are tons of additional extensions you can load that cover just about everything and anything you can think of: From writing and manipulating Flash, PDF, Image files from code to special xml functions to secure shopping cart extensions. Most of the time it's hard to convince your systems admin to enable some of these extensions for you if your in a shared hosting environment - but in this case since we are the systems Admin we can do whatever we want.
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).
(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.
Next we'll Take on installing MySQL
Installing MySQL 3.23.49
First where going to have to download MySQL
You can download MySQL 3.23 here: http://www.mysql.com/downloads/mysql-3.23.html
Or more specifically here: Download (mysql-3.23.49-win.zip)
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.
Create a PHP script called 'TestSQL.php'. Then add the following to that file.
<?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 information on using the command line from the DOS prompt or from Telnet read the first part of this.
For further information on MySQL and a great reference manual visit - http://www.mysql.com/doc/.
Installing and Using PHPMyAdmin
First we need to download PHPMyAdmin, you can do so here: http://www.phpmyadmin.net (phpMyAdmin-2.2.6-php.zip)
Or more specifically here: Download phpMyAdmin-2.2.6-php.zip
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\
This will create a directory structure such as: C:\Program Files\Apache Group\Apache2\htdocs\phpMyAdmin-2.2.6. Rename this directory to something easier to remember such as 'Admin' - So now it's C:\Program Files\Apache Group\Apache2\htdocs\Admin\
When you open the files for PHPmyAdmin you just downloaded, you'll notice that the code inside of them is jumbled together with no real line breaks and some extra weird symbols in their. The reason for this is that Unix and Windows have slightly different ways of using line breaks in Text files. This makes it difficult to edit the 1 file we need to before getting started - It also seems to not work quite right when it's in this state.
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 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.
There's probably an easier way to do this...
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.
Open up the URL: http://localhost/Admin/index.php (or wherever you installed PHPMyAdmin). You should see a page with "Welcome to phpMyAdmin 2.2.6". This means you where successful. If this was not successful try refreshing the page and emptying your browser cache once in a while it doesn't read in the updated config.inc.php file right away, also check the documentation for PHPMyAdmin and try a couple of different setups of the config.inc.php file. Try to become familiar with how this is set up. Well go into some details of how to use this on the next page.
Using PHPMyAdmin and a Simple Example of creating a Flash Database app
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'.
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:
| Field | Type | Value | Extra | (other) |
| ID | INT | auto_increment | Check primary key | |
| UserName | Varchar | 30 | ||
| News | Text | |||
| TimeAdd | Date |
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!
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) )
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.
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
| » Level Advanced |
Added: : 2002-05-08 Rating: 9.21 Votes: 105 Hits: 3173 |
| » Author |
| Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services. |
| » Download |
| Download the files used in this tutorial. |
| Download (30 kb) |
discuss this topic to forum
