php 字符串到 flash 变量

发布于 2024-12-13 14:48:45 字数 1146 浏览 0 评论 0原文

我在一个项目中使用 AS3,我必须将一些 flash 变量发送到 PHP,检查 MySQL 数据库并将一些结果返回到 Flash。我这样做是这样的: new URLRequest(URL + "?p=" + SelectedCountry + "&action=check&nocache=" + Math.floor(Math.random() * (10000000)));

和 php代码只是检查 MySQL 是否存在包含所选国家/地区的行:

if($_REQUEST['action'] == "check") {

    $q = mysql_query("SELECT * FROM myDB WHERE country = '".$_REQUEST['p']."'");

    if(mysql_num_rows($q) == 0) {
        echo "nqma";
    } else {
        echo "ima";
    }
}

好的,这很好,它可以工作,因为我可以在 Flash 中使用它:

if(e.target.data == "ima") {
    uiRepCountryLabel.text = "Ima";
} 
if(e.target.data == "nqma") {
    uiRepCountryLabel.text = "Nqma";
}

但是如果我想让 php 结果看起来像这样怎么办:

if($_REQUEST['action'] == "check") {
    $q = mysql_query("SELECT * FROM myDB WHERE country = '".$_REQUEST['p']."'");
    if(mysql_num_rows($q) == 0) {
        echo "res=nqma";
    } else {
        echo "res=ima&hisCountry=Bulgaria&hisPhoneNumber=000000123&hisCity=Svishtov&his.....";
    }
}

如何我可以在 Flash 中使用这种格式吗?我知道,你们中的许多人会告诉我使用 AMFPHP,但我不能,因为我的客户不想这样做。

I am using AS3 for a project and I have to send some flash variables to PHP, check the MySQL databese and the to return some results to Flash. I do this with this:
new URLRequest(URL + "?p=" + SelectedCountry + "&action=check&nocache=" + Math.floor(Math.random() * (10000000)));

and the php code just checks the MySQL if there is a row with the selected country:

if($_REQUEST['action'] == "check") {

    $q = mysql_query("SELECT * FROM myDB WHERE country = '".$_REQUEST['p']."'");

    if(mysql_num_rows($q) == 0) {
        echo "nqma";
    } else {
        echo "ima";
    }
}

OK, that's fine and it works, because I can use this in Flash:

if(e.target.data == "ima") {
    uiRepCountryLabel.text = "Ima";
} 
if(e.target.data == "nqma") {
    uiRepCountryLabel.text = "Nqma";
}

But what if I want to make the php result to look like this:

if($_REQUEST['action'] == "check") {
    $q = mysql_query("SELECT * FROM myDB WHERE country = '".$_REQUEST['p']."'");
    if(mysql_num_rows($q) == 0) {
        echo "res=nqma";
    } else {
        echo "res=ima&hisCountry=Bulgaria&hisPhoneNumber=000000123&hisCity=Svishtov&his.....";
    }
}

How can I use this format In Flash? I know, that many of you will tell me to use AMFPHP, but I am not able, because my client doesn't want to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鼻尖触碰 2024-12-20 14:48:45

像这样的东西:

var appheader:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); 
var urlRequest:URLRequest = new URLRequest(URL + "?p=" + SelectedCountry + "&action=check&nocache=" + Math.floor(Math.random() * (10000000)));

urlRequest.requestHeaders.push(appheader);
urlRequest.method = URLRequestMethod.POST;

var urlloader:URLLoader = new URLLoader(urlRequest);
urlloader.addEventListener(Event.COMPLETE, onUploadComplete);
urlloader.dataFormat = URLLoaderDataFormat.VARIABLES; 
urlloader.load(urlRequest);

urlloader.addEventListener(IOErrorEvent.IO_ERROR, handleGetSessionIOError);
}



function handleGetSessionIOError(e:IOErrorEvent):void {   
 trace("handleGetSessionIOError "+e);

}



function onUploadComplete(e:Event):void {   
trace("uploaded to server."+e.target.data);

}

Something like this:

var appheader:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); 
var urlRequest:URLRequest = new URLRequest(URL + "?p=" + SelectedCountry + "&action=check&nocache=" + Math.floor(Math.random() * (10000000)));

urlRequest.requestHeaders.push(appheader);
urlRequest.method = URLRequestMethod.POST;

var urlloader:URLLoader = new URLLoader(urlRequest);
urlloader.addEventListener(Event.COMPLETE, onUploadComplete);
urlloader.dataFormat = URLLoaderDataFormat.VARIABLES; 
urlloader.load(urlRequest);

urlloader.addEventListener(IOErrorEvent.IO_ERROR, handleGetSessionIOError);
}



function handleGetSessionIOError(e:IOErrorEvent):void {   
 trace("handleGetSessionIOError "+e);

}



function onUploadComplete(e:Event):void {   
trace("uploaded to server."+e.target.data);

}
千年*琉璃梦 2024-12-20 14:48:45

您可以将其添加到 Crooksy 的帖子中:

function onUploadComplete(e:Event)
{   
    var phpvars:URLVariables = new URLVariables(event.target.data);

    trace(phpvars.res,phpvars.hisCountry);
}

You could add this to crooksy's post:

function onUploadComplete(e:Event)
{   
    var phpvars:URLVariables = new URLVariables(event.target.data);

    trace(phpvars.res,phpvars.hisCountry);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文