Skip to main content
Participating Frequently
September 7, 2007
Question

LoadVars and PHP

  • September 7, 2007
  • 23 replies
  • 1719 views
I'm trying to use LoadVars to bring a user ID into Flash from a PHP page and then put the user ID into a dynamic text box. The user ID is created from 2 separate numbers that are received via a form. The problem is that I can't get Flash to load the variable. If I hardcode a number in then everything works fine, but it Flash doesn't seem to like dynamically created variables.

php code that works:
<?php echo "&qID=54564656&"; ?>

php code that doesn't work. With this one the Flash text field is blank. It doesn't even read "undefined".
<?php
$subDB = substr($_POST["quizDB"], 4);
$qID = $subDB.$_POST["quizNum"];
echo "&qID=".$qID."&";
?>

Flash code:
fromQuiz = new LoadVars();
fromQuiz.load("test.php");

fromQuiz.onLoad = function()
{
ID_txt.text = fromQuiz.qID;
}


Thanks
This topic has been closed for replies.

23 replies

Inspiring
September 7, 2007
@clbeech - I don't think that will make a difference - I think the first ampersand is treated the same as the subsequent name/value delimiteres.. not 100% sure... but based on the fact that the hard-coded value was working... I don't think that will change things.
Inspiring
September 7, 2007
There are no POST variables. Probably should be more like this (not syntax checked).

fromQuiz = new LoadVars();
toQuiz = new LoadVars();
fromQuiz.quizBD="SOMETHING";
fromQuiz.quizNum=500;
fromQuiz.sendAndLoad("test.php",toQuiz,"POST");

toQuiz.onLoad = function()
{
ID_txt.text = this.qID;
}
clbeech
Inspiring
September 7, 2007
No this should work fine with Flash, but you should call the right variable in the onload. in the echo you have a variable named '&qID' which is what Flash is looking for, and in the onLoad you have just 'qID'

change to:

ID_txt.text = fromQuiz.&qID;
SW_FuzeAuthor
Participating Frequently
September 7, 2007
Flash insists that I have the first "&" in the string or it won't work.