Flash and php p {margin-bottom: 0.08in ;}
Flash and asp:
Paste the following two codes:
Flash:
Webpage Tutorial network
Var loader: URLLoader = new URLLoader ();
Var url: URLRequest = new URLRequest ("test. asp ");
Url. method = URLRequestMethod. POST;
Var values: URLVariables = new URLVariables ();
Values. message = "hello im flash! ";
Url. data = values;
Loader. dataFormat = URLLoaderDataFormat. VARIABLES;
Loader. addEventListener (Event. COMPLETE, loaded );
Function loaded (e: Event ){
Out1.text = loader. data;
// OutPut: phpMessage = im php message! & FlashMessage = hello im flash!
Out2.text = loader. data. phpMessage;
// Im php message!
Out3.text = loader. data. flashMessage;
// Hello im flash!
Out4.text = loader. data. dbMessage;
}
Loader. load (url );
Webpage Tutorial network
Webpage Tutorial network
Asp:
Webjx. Com
<% @ LANGUAGE = "JAVASCRIPT" %>
<%
// Receives data from flash.
Var flashData;
FlashData = Request ("message ");
// Data sent to flash
Var aspMessage;
AspMessage = 'im asp message! ';
// Database operations
// ================================================
Var conn;
Var rs;
Var SQL;
Var strPath;
StrPath = "test. mdb ";
Try {
Conn = Server. CreateObject ("ADODB. Connection ");
Conn. connectionString = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" + Server. MapPath (strPath );
Conn. open ();
} Catch (e ){
Response. Write ('
Database connection error. check the connection string!
');
Response. End
}
Rs = Server. createobject ("ADODB. Recordset ");
SQL = "select * from name ";
Rs. open (SQL, conn, 1, 1 );
// ================================================
Response. Write ("phpMessage =" + aspMessage + "&" + "flashMessage =" + flashData + "&" + "dbMessage =" + rs ("companyname "));
%>
Webjx. Com
When you see flash and asp files, the variable names will know how they are transmitted. for some database insertion, update, and query operations, you only need to receive flash data, you can directly run the asp-related database operation commands. directly copy to the IIS path to test. online viewing address: PLETE, loaded );
Function loaded (e: Event ){
Out1.text = loader. data;
// OutPut: phpMessage = im php message! & FlashMessage = hello im flash!
Out2.text = loader. data. phpMessage;
// Im php message!
Out3.text = loader. data. flashMessage; Webjx. Com
// Hello im flash!
Out4.text = loader. data. dbMessage;
}
Loader. load (url );
Php:
Webjx. Com
Webjx. Com
// Database operations are involved here
// ============================================
Define ('database _ server', 'localhost ');
Define ('database _ username', 'root ');
Define ('database _ password', 'root ');
Define ('database _ name', 'flextest ');
$ Link = @ mysql_connect (DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD );
@ Mysql_select_db (DATABASE_NAME, $ link );
$ Result = @ mysql_query ("Select * from users ");
$ User = @ mysql_fetch_array ($ result, MYSQL_ASSOC );
// Echo $ user ['userid'];
$ Dbvar = $ user ['userid'];
// ============================================
// Receives data from flash.
$ FlashData = $ _ POST ['message'];
// Data sent to flash
$ PhpMessage = 'im php message! ';
Echo "phpMessage = $ phpMessage & flashMessage = $ flashData & dbMessage = $ dbvar ";
?>
Webjx. Com
The code is very simple and does not need to be explained much. In fact, there are no major differences with asp. directly copy to the php path to test. the database file runs flextest directly under phpMyAdmin. the SQL statement in SQL is enough. because the company has disabled ports, I cannot operate SQL databases in my space online. I don't have an online demo address. I will add it at home when I have time.
Flex and php:
Paste the following two codes:
Flex:
Webjx. Com
Webjx. Com
</p> <p> public function onInit():void </p> <p> { </p> <p> userRequest.send(); </p> <p> } Webjx.Com </p> <p>
{Username. text} {Emailaddress. text}
Webjx. Com
Php:
Webpage Tutorial network
/* Thanks to Pete Macie for the code below */
Define ('database _ server', 'localhost ');
Define ('database _ username', 'root ');
Define ('database _ password', 'root ');
Define ('database _ name', 'flextest ');
# Connect to the database
$ Mysqli = new mysqli (DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME );
# Check connection
If (mysqli_connect_errno ()){
Printf ("MySQL connect failed: % s \ n", mysqli_connect_error ());
Exit ();
}
# Quote variable to make safe
Function quote_smart ($ value ){
Global $ mysqli;
Webjx. Com
# Stripslashes
If (get_magic_quotes_gpc ())
$ Value = stripslashes ($ value );
# Quote if not integer
If (! Is_numeric ($ value ))
$ Value = $ mysqli-> real_escape_string ($ value );
Return $ value;
}
If (! Empty ($ _ POST) & $ _ SERVER ['request _ method'] = 'post '){
If ($ _ POST ['emailaddress'] & $ _ POST ['username']) {Webpage Tutorial network
# Add the user
$ Query = sprintf ("Insert INTO users VALUES ('', '% s',' % s') ", quote_smart ($ _ POST ['username']), quote_smart ($ _ POST ['emailaddress']);
If (! @ $ Mysqli-> query ($ query )){
Printf ("'flextest' user database query insert error: % s \ n", $ mysqli-> error );
$ Mysqli-> close ();
Webjx. Com
Exit ();
}
}
}
# Return a list of all the users
If (! $ Result = @ $ mysqli-> query ("Select * from users ")){
Printf ("'flextest' user database query select error: % s \ n", $ mysqli-> error );
$ Mysqli-> close ();
Exit ();
}
$ Xml_return =" ";
While ($ user = mysqli_fetch_array ($ result, MYSQLI_ASSOC )){
$ Xml_return. = Webjx. Com
" ". $ User ['userid']." ". $ User ['username']." ". $ User ['emailaddress']." \ N ";
}
$ Xml_return. ="";
$ Mysqli-> close ();
Echo $ xml_return;
?>
The code here is an instance in Adobe phpria sdk. if you want all source code, please leave your email and I will send it. flex and php will not talk about it, just convert the php code into asp code, and work with flash.