Flash + PHP + Mysql simple message book production example tutorial

Source: Internet
Author: User
& Nbsp; at the beginning of this message book, I had no contact with MySQL or php. After a week of hard work, I completed my simple message book. There are no good PHP message book tutorials on the internet. The N multiple source files I downloaded are all in the fog of the cloud, and many of them write code on MC. Maybe I haven't found any good tutorials, but in any case, I have to make an axe at this class. Purpose: I have never been in touch with MySQL or php before using Flash + php + my to make this message book. After a week of hard work, I completed my simple message book. There are no good PHP message book tutorials on the internet. The N multiple source files I downloaded are all in the fog of the cloud, and many of them write code on MC. Maybe I haven't found any good tutorials, but in any case, I have to make an axe at this class. Purpose:

Use Flash + php + mysql to create a simple message book.

Configure the environment:

You must first configure the corresponding environment. I downloaded the environment package configuration, which is a silly method and simple installation, which is suitable for me. : Http://phpnow.org/download.html (including: Apache, PHP, MySQL, Zend Optimizer, phpMyAdmin, eAccelerator)

The folder is described as follows (Init. cmd installation; PnCp. cmd control panel .) :


Apache folder: PHP Server (similar to IIS ).
MySQL-5.0.15b folder: MySQl database server.
Data folder: stores the website database. (The message book database is stored in this, background)
Bin folder: files in it are used to operate databases (DOS mode)
Php-5.2.6-Win32 folder: PHP library, explained by Apache.
ZendOptimizer folder: accelerates PHP execution.
Htdoc (or www): stores webpage files. (The webpage file of the message book is stored at the front-end)
PhpMyAdmin folder: operate databases (in Windows mode)

  Note:

1. during installation, you will be prompted to enter the MySQl database password. here, the password takes "sun" as an example. (The user name is "root ")


2. enter "http: // 127.0.0.1" in the browser and the configuration information is displayed. you can enter the MySQl password for connection testing.


3. The website directory index is disabled by default. you can enable it on the console to facilitate subsequent tests on the website (message board.



Knowledge preparation:

1. first introduce how to use PHP to connect to the database (database username "root", password "sun", database "myguestbook ")


2. communication between PHP and MySQl (SQL statement: INSERT, SELECT ):
PHP prepare MySQl: SELECT * FROM myguestbook;
PHP → MySQL: insert into myguestbook (name, comment) VALUE ("zhang san", "This is a message ");

3. SWF and PHP communication (the sendAndLoad method of the LoadVars class is saved, and the xml Parsing method is used ):
SWF merge PHP: PHP uses echo to write an xml file, and SWF directly parses the file. (I used to wonder why the blue rss is in the PHP format. I learned it here to understand it .)
SWF → PHP: swf uses "sendAndLoad" (data_lv.uname = "Zhangsan") to send Variables. php uses $ name =$ _ POST ['uname'] to receive variables.

  Note:
1. the message book is actually two small processes. PHP is equivalent to a bridge. We strongly recommend that you write a simple example of both 2 and 3. if the example runs successfully, the message book has completed more than half of it before it starts writing.
2. sendAndLoad can both send variables to php and receive php variables (similar to swf reading text ). You can refer to the volcano tutorial for details.

Start Production (make the above preparations and the following will be well understood ):


1. SWF reads data
① And ② MySQl → PHP → SWF
PHP uses "SELECT" to retrieve from MySQl and then writes xml to SWF for reading.


Figure 8

2. SWF stores data
③ And ④ SWF → PHP → MySQl
SWF uses "sendAndLoad" to PHP, and PHP uses "INSERT" to MySQl.


Figure 9 click to zoom in

After completion:


0

Other considerations:

Solve the garbled text (solve the problem of reading Chinese in the database "???? "):
Select utf8-geeral-ci encoding when you create a database with PhpAdmin.
Before the php file query statement, add: mysql_query ("set names 'utf8 '");
Php modularization (easy to modify later ):
The database connection statement is written in a separate file, such as connectdb. php.
Add require "connectdb. php" to the file where data is written (datatosql. php) and data is read (datatoxml. php.
MySQL troubleshooting function (if the operation is incorrect, it will be easily modified as prompted ):
Mysql_errno (error number); mysql_error (error cause ).
Php date functions (for more details, refer to other help ):
Data ("Ymd, l, H: I"); // 20080608, Sunday
SWF real-time refresh (ensure to read the latest data ):
Swf sends and obtains the real-time variable: data_lv.sendAndLoad ("datatosql. php? N = "+ random (9999), data_lv," post ");
Swf reads real-time xml: myXML. load ("datatoxml. php? N = "+ random (9999 ))

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.