2

我是使用 xamp 集成 Flash、php 和 mysql 的新手。我尝试了很多来纠正这个错误,但我不能这样做,因为我不知道这个错误是在 php 页面中还是值没有传递给 php。

这是我的 AS3 代码:

public function processLogin ():void {


            trace("inside the processlogin method");

            var phpVars:URLVariables = new URLVariables();

            var phpFileRequest:URLRequest = new URLRequest("controlpanel.php");         
            phpFileRequest.method = URLRequestMethod.POST;          
            var phpLoader:URLLoader = new URLLoader();
            phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;           
            phpLoader.addEventListener(Event.COMPLETE, showResult);

            phpVars.Username = Username.text;
            trace(phpVars.Username);
            phpVars.password = password.text;
            trace(phpVars.password);
            phpFileRequest.data = phpVars;
            trace("phpvariable"+phpVars);
            phpLoader.dataFormat=URLLoaderDataFormat.TEXT;
            phpLoader.load(phpFileRequest);

        }

        public function showResult (event:Event):void {             
            trace("show result");           
            result_text.autoSize = TextFieldAutoSize.LEFT;      
            result_text.text = "" + event.target.data.systemResult;
            trace(event.target.data.systemResult);  
        }

    }

这是控制台中的输出:

sucess
now im in checklogin
inside the processlogin method
raj
raj
phpvariableUsername=raj&password=raj
starts process login method
show result
ReferenceError: Error #1069: Property systemResult not found on String and there is no default value.
    at actions::main/showResult()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

对应的php页面是

<html>
<body><?php 
include("connect.php");
 $username = $_POST['Username'];
 $password = $_POST['password'];
$query = mysql_query("SELECT * FROM users WHERE username='$Username' AND password='$password'");
$login_counter = mysql_num_rows($query);
while ($data = mysql_fetch_array($query)) 
{
$userbio = $data['user_bio'];
print "systemResult=$userbio";
}
?>
</body>
</html>
4

1 回答 1

0

错误消息说明了一切 -event.target.data是一个字符串 - 没有属性systemResult

看看event.target.data,这应该是响应的 html 代码。

于 2012-05-05T14:06:17.413 回答