Php and swf communication

Source: Internet
Author: User
Php and swf communication SWF and PHP communication (the sendAndLoad method of the LoadVars class is saved, and the XML Parsing method is obtained ):
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.


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


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: 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.