MySQL,PhP, and Flash As3 Data is not loading properly?

纵然是瞬间 提交于 2019-12-25 04:22:54

问题


For some reason the PHP variables are loading very improperly. So this is what happens:

In my PHP code I have:

<?php
include_once "connect.php";

$username = $_POST['username'];
$password = $_POST['password'];

if ($_POST['systemCall'] == "checkLogin") {

    $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";

    $query = mysql_query($sql);

    $login_counter = mysql_num_rows($query);

    if ($login_counter > 0) {
        while ($data = mysql_fetch_array($query)) {

            $testing = $data["testing"];
            $userbio = $data["user_bio"];

            print "thetesting=$testing";
            print "theuserbio=$userbio";
        }
    } else {
        print "theuserbio=The login details dont match our records.";
    }
}
?>

Then in my AS3 Code I have:

import flash.text.*;


result_text.autoSize = TextFieldAutoSize.LEFT;

result_text.text = "" + event.target.data.theuserbio;
result_text2.text = "" + event.target.data.thetesting

What happens is that whenever I login using the correct credentials the result_text.text will say undefined.

But the result_text2.text will say: HELLOtheuserbio=this is the user bio.

Basically whats happening is that the result_text2 is saying both theuserbio and thetesting. While result_text is saying undefined.

How do I make it so that result_text says the data inside theuserbio, and result_text2 says the data inside thetesting?


回答1:


Add ampersand between prints

print "thetesting=$testing";
print "&";
print "theuserbio=$userbio";

And check that you have this line:

urlloader.dataFormat = URLLoaderDataFormat.VARIABLES;


来源:https://stackoverflow.com/questions/28545198/mysql-php-and-flash-as3-data-is-not-loading-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!