Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
echo未在php actionscript连接上返回变量值_Php_Mysql_Flash_Actionscript_Echo - Fatal编程技术网

echo未在php actionscript连接上返回变量值

echo未在php actionscript连接上返回变量值,php,mysql,flash,actionscript,echo,Php,Mysql,Flash,Actionscript,Echo,我正在尝试将一些变量从php传递到flash,我使用以下actionscript代码: public function gameOver(score:Number) { totalScore.text = score.toString(); var scriptVars:URLVariables = new URLVariables(); scriptVars.score = score; var scriptLoader:URLLoader = new U

我正在尝试将一些变量从php传递到flash,我使用以下actionscript代码:

public function gameOver(score:Number) 
{
    totalScore.text = score.toString();

    var scriptVars:URLVariables = new URLVariables();
    scriptVars.score = score;

    var scriptLoader:URLLoader = new URLLoader();

    var scriptRequest:URLRequest = new URLRequest("checkScores.php");
    scriptRequest.method = URLRequestMethod.POST;
    scriptRequest.data = scriptVars;

    scriptLoader.load(scriptRequest);
    scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
    scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);
}

function handleLoadSuccessful(e:Event):void
{
    trace("Scores Loaded");
    var vars:URLVariables = new URLVariables(e.target.data);
    nickname1.text = vars.nickname;
    score1.text = vars.score;
}

function handleLoadError($evt:IOErrorEvent):void
{
    trace("Load failed.");
    nickname1.text ="error";
}
下面是php代码:

<?php
    ... some code for the mysql connection and select sentence ...

        $topScores = mysqli_query($con, $topScores);
        $topScores = mysqli_fetch_array($topScores);
        echo "&nickname=$topScores[nickname]&score=$topScores[score]";

?>
对于vars.score

$topScores[score]
如果我单独运行php,我会得到以下结果:

&nickname=jonny&score=100

这是我试图获取的实际变量值,如果您能提供任何帮助,我们将不胜感激。

我想您可能只是在从flash中将php文件作为文本文件加载。你能改一下吗

new URLRequest("checkScores.php");
例如:

new URLRequest("http://localhost/checkScores.php");

或者,当您按照问题中的说明“运行”浏览器地址栏时,在浏览器地址栏中看到的任何内容。

它起作用了!但是我得到了一个新的错误,错误#2101:传递给URLVariables.decode()的字符串必须是包含名称/值对的URL编码查询字符串。我修复了将我的php echo sintax更改为echo“昵称=.urlencode($topScores['昵称])”&score=“.$topScores['score'”;非常感谢你!
new URLRequest("http://localhost/checkScores.php");