0

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?

4
  • Please post your PHP code inline here. And indent it. Commented Feb 16, 2015 at 15:49
  • Your PHP looks to SQL injection vulnerable, FYI. Commented Feb 16, 2015 at 15:53
  • Thanks Aaron, but I don't really mind for now I'm trying to get this to work. Commented Feb 16, 2015 at 16:09
  • I added the PhP code here. Commented Feb 16, 2015 at 16:11

1 Answer 1

2

Add ampersand between prints

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

And check that you have this line:

urlloader.dataFormat = URLLoaderDataFormat.VARIABLES;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.