PHP and SwF Communication

Source: Internet
Author: User
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 ):

Figure 1

1. SWF reads data
① And ② MySQL → PHP → SWF
PHP uses "select" to retrieve from MySQL and then writes XML to SwF for reading.


Figure 2

2. SWF stores data
③ And ④ SWF → PHP → MySQL

SWF uses "sendandload" to PhP, and PHP uses "insert" to MySQL.

Figure 3

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) reference from: http://dodomail.javaeye.com/blog/211003

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.