【问题标题】:Undefined index when trying to GET variable尝试获取变量时未定义的索引
【发布时间】:2013-05-21 01:53:24
【问题描述】:

在我的 Flash 文件中,我有以下 Actionscript 代码:

gameEnd.submitBtn.removeEventListener(MouseEvent.MOUSE_DOWN, submitScore);

submitScore函数如下:

public function submitScore(e:MouseEvent):void
    {
        this.addChild(scoreAdded);
        scoreAdded.x = 165;
        scoreAdded.y = 85;

        var url:URLRequest = new URLRequest("./submitscore.php");
        var thevariables:URLVariables = new URLVariables();
        url.method = "GET";
        thevariables.score = scoreText.text;
        url.data = thevariables;
        navigateToURL(url,"_self");
    }

在我的submitscore.php 文件中,我有:

<?php

$scorefromflash = $_GET['score'];
echo ("Score: ".$scorefromflash);

?>

但这会导致错误Notice: Undefined index: score in submitscore.php。任何人都知道为什么这不起作用?我以完全相同的方式完成了名称和分数,但使用了不同的变量名称并且分数永远不会起作用。

我非常感谢任何帮助,因为我今天确实需要解决这个问题。

【问题讨论】:

标签: php actionscript-3 flash


【解决方案1】:

您忘记将score 添加到thevariables

var thevariables:URLVariables = new URLVariables();
thevariables.score = submitScore;

然后将wm添加到请求中:

url.data = thevariables;

【讨论】:

  • 当我想输出 nameText.text 而不是 scoreText 时,我真的很困惑为什么它可以工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-14
  • 1970-01-01
  • 2017-02-02
相关资源
最近更新 更多