简体   繁体   中英

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

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 ?

Add ampersand between prints

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

And check that you have this line:

urlloader.dataFormat = URLLoaderDataFormat.VARIABLES;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM