Undefined Variable in Flash CS4 AS2

  • khaled_hassan
  • Born
  • Born
  • khaled_hassan
  • Posts: 1

Post 3+ Months Ago

Hi,
I am making a log in screen and I sent the data from Flash to php and I send a variable from the php to flash but the variable keeps tracing undefined and I don't know what is the problem
here is the flash code:
The button:
Code: [ Select ]
on (release, keyPress "<Enter>")
{
var myVars= new LoadVars ();
myVars.user = username.text;
myVars.pass = pass.text;
myVars.sendAndLoad("http://localhost/Checklogin.php",0,"POST");
gotoAndPlay(2);
}
  1. on (release, keyPress "<Enter>")
  2. {
  3. var myVars= new LoadVars ();
  4. myVars.user = username.text;
  5. myVars.pass = pass.text;
  6. myVars.sendAndLoad("http://localhost/Checklogin.php",0,"POST");
  7. gotoAndPlay(2);
  8. }


Frame 2:
Code: [ Select ]
stop();
var myData = new LoadVars();


myData.onLoad = function(success) {
    if(success)
    {
    myData.myvar = Number (myVar);
      trace("I am connected");
      trace(myVar);
    }
    else
    {
        trace("I am not connected");
    }
}

myData.load("http://localhost/checklogin.php");

if(myVar == 1)
{
    gotoAndPlay(3);
}
else if(myVar == 0)
{
    gotoAndPlay(4);
}
  1. stop();
  2. var myData = new LoadVars();
  3. myData.onLoad = function(success) {
  4.     if(success)
  5.     {
  6.     myData.myvar = Number (myVar);
  7.       trace("I am connected");
  8.       trace(myVar);
  9.     }
  10.     else
  11.     {
  12.         trace("I am not connected");
  13.     }
  14. }
  15. myData.load("http://localhost/checklogin.php");
  16. if(myVar == 1)
  17. {
  18.     gotoAndPlay(3);
  19. }
  20. else if(myVar == 0)
  21. {
  22.     gotoAndPlay(4);
  23. }


The PHP code:
Code: [ Select ]

<?PHP

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

$connection = oci_connect('system', 'rms2010', 'ORACLE');
if (!$connection)
    {
echo ("Couldn't make a connection!");
exit;
    }
if ($connection)
    {
echo ("connected");
    }

$sql = "SELECT COUNT(*) AS num_rows FROM CUSTOMER WHERE CUSTOMER_ID = '$username' AND CUSTOMER_PASSWORD = '$password'";
$sql_statement = oci_parse($connection,$sql);
oci_define_by_name($sql_statement,"NUM_ROWS",$num_rows);
oci_execute($sql_statement);
oci_fetch($sql_statement);



if ($num_rows == 1)
{

  $myvar == 1;
  echo ("&myvar=1");
}
else if($num_rows == 0)
{
  
  $myvar == 0;
  echo ("&myvar=0");
}
//print ($num_rows);

oci_close($connection);

?>
  1. <?PHP
  2. $username = $_POST['user'];
  3. $password = $_POST['pass'];
  4. $connection = oci_connect('system', 'rms2010', 'ORACLE');
  5. if (!$connection)
  6.     {
  7. echo ("Couldn't make a connection!");
  8. exit;
  9.     }
  10. if ($connection)
  11.     {
  12. echo ("connected");
  13.     }
  14. $sql = "SELECT COUNT(*) AS num_rows FROM CUSTOMER WHERE CUSTOMER_ID = '$username' AND CUSTOMER_PASSWORD = '$password'";
  15. $sql_statement = oci_parse($connection,$sql);
  16. oci_define_by_name($sql_statement,"NUM_ROWS",$num_rows);
  17. oci_execute($sql_statement);
  18. oci_fetch($sql_statement);
  19. if ($num_rows == 1)
  20. {
  21.   $myvar == 1;
  22.   echo ("&myvar=1");
  23. }
  24. else if($num_rows == 0)
  25. {
  26.   
  27.   $myvar == 0;
  28.   echo ("&myvar=0");
  29. }
  30. //print ($num_rows);
  31. oci_close($connection);
  32. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Code: [ Select ]
myData.myvar = Number (myVar);

Capital "V" vs. small "v" perhaps?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

That and I don't see any place where you define myVar inside of Flash. try tracing myData.myvar instead or possibly just myData. I believe that will return an array or all the other data available.
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Code: [ Select ]
myData.myvar = Number (myVar);

Not too sure why you are setting this up like this but to me it seems like it should be switched like
Code: [ Select ]
myVar = Number (myData.myvar);

Because like graphixbox said i don't see where you are declaring the varible.

the way i see that code, your return info gets reset with something else which may or may not exist before you do anything with it.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 22 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.