将AS3与PHP通信。将变量发送到php页面,但$\u POST为空

将AS3与PHP通信。将变量发送到php页面,但$\u POST为空,php,mysql,actionscript-3,flash,Php,Mysql,Actionscript 3,Flash,我使用FlashCS5.5创建了一个简单的测验程序,它将测验结果发送到php页面,php页面将这些数据写入Mysql数据库。 因此,我尝试使用$\u POST将简单变量从swf文件发送到php页面。我正在使用WAMP执行php页面 我总共创建了3个文件: 1.mioQuizDB.swf 2.config.php 3.inserimentoDati.php 因此mioQuizDB.swf与inserimentoDati.php通信,后者与config.php通信以连接到数据库和Mysql数据库 我

我使用FlashCS5.5创建了一个简单的测验程序,它将测验结果发送到php页面,php页面将这些数据写入Mysql数据库。 因此,我尝试使用$\u POST将简单变量从swf文件发送到php页面。我正在使用WAMP执行php页面

我总共创建了3个文件: 1.mioQuizDB.swf 2.config.php 3.inserimentoDati.php

因此mioQuizDB.swf与inserimentoDati.php通信,后者与config.php通信以连接到数据库和Mysql数据库

我的问题是: 1.当URLRequest完全加载时,inserimentoDati.php不会自动打开; 2.在inserimentoDati.php中,$\u POST是空的,我不知道为什么。 这是mioquick.swf:

这是inserimentoDati.php:

试试这个

  // Assign a variable name for our URLVariables object
    var variables:URLVariables = new URLVariables();
    // Build the varSend variable
    // Be sure you place the proper location reference to your PHP config file here
    var varSend:URLRequest = new URLRequest("http://www.yourwebsite.com/config_flash.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    // Build the varLoader variable
    var varLoader:URLLoader = new URLLoader;
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

    varLoader.addEventListener(Event.COMPLETE, completeHandler);

    variables.uname = "myvalue whatever its...";
    variables.sendRequest = "parse"; 
    // Send the data to the php file
    varLoader.load(varSend);

    // When the data comes back from PHP we display it here 
    function completeHandler(event:Event):void
    {

    var value1= event.target.data.var1;
    var value2 = event.target.data.var2;

     trace(value1);
     trace(value2 );

    }

我已经查看了其他关于此参数的讨论,但没有找到解决方案。请检查http服务器访问日志文件。可能参数只是作为GET参数发送的。15分钟后仍在等待代码,我退出。您确定要以POST方式发送请求吗?varSend.method=URLRequestMethod.POST;不是吗?嗨,阿卡夏,对不起,我迟到了。检查http服务器访问日志文件是什么意思?我可以在哪里检查它?嗨,sajan kumar,这正是我最初尝试执行的开源程序,但这两个程序都不能正常工作。我的文件位于名为wamp/www/.mmm.的文件夹中。奇怪,请删除内容类型application/x-www-form-urlencoded。我不确定这是否有效。。试试看。。我检查了你的代码,它是完全正确的。萨扬·库马尔,那行是正确的。现在它工作了!!:问题是:在config.php文件的第10行,mysql\u select\u db$database应该是mysql\u select\u db'vhfdb',而不是使用$database变量!我通过查看服务器错误日志文件找到了答案!那太奇怪了。。您将数据库名称存储在一个变量中,并将其传递到mysql\u select\u db中。。我很高兴这对你有用
<?php
    if(isset($_POST['sendRequest'])){
    if( $_POST['sendRequest']=="scriviDatiUtente" ) {
    include "config.php";

    //I transfer my data in some variables from $_POST (which is empty -__- )
    $nome = $_POST['unome'];
    $cognome = $_POST['ucognome'];
    $codice = $_POST['ucodice'];
    $punteggio = $_POST['upunteggio'];

    //I insert data in Mysql database
    $querya = "INSERT into studente(id, nome, cognome) values('$codice', '$nome', '$cognome')";
    $inserimentoa = mysql_query($querya, $database);
    $queryb = "INSERT into esecuzione(punteggio, id_studente) values('$punteggio', '$codice')";
    $inserimentob = mysql_query($queryb, $database);
    mysql_close($database);
    }
    }
?>
<?php
    $host="localhost";
    $user="root";
    $password="";
    $database="vhfdb";

    //connessione a mysql
    $database = mysql_connect($host, $user, $password) or die(mysql_error());
    //seleziono in mysql il database vhfdb
    mysql_select_db($database) or die(mysql_error());
?>
  // Assign a variable name for our URLVariables object
    var variables:URLVariables = new URLVariables();
    // Build the varSend variable
    // Be sure you place the proper location reference to your PHP config file here
    var varSend:URLRequest = new URLRequest("http://www.yourwebsite.com/config_flash.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    // Build the varLoader variable
    var varLoader:URLLoader = new URLLoader;
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

    varLoader.addEventListener(Event.COMPLETE, completeHandler);

    variables.uname = "myvalue whatever its...";
    variables.sendRequest = "parse"; 
    // Send the data to the php file
    varLoader.load(varSend);

    // When the data comes back from PHP we display it here 
    function completeHandler(event:Event):void
    {

    var value1= event.target.data.var1;
    var value2 = event.target.data.var2;

     trace(value1);
     trace(value2 );

    }