Jump to content

php into flash


xcandiottix

Recommended Posts

Does anyone have experience getting php variables into flash? I've tried a lot of different how-to's online but they are vary too much to get anything working. I'd like something very basic just to get it to work.. after that I can make it do what I want. Currently, I've set up a PHP page that gets my needed variable and then:

 

print var1 = cheese

 

In flash, I've tried a variety of ways to get var1 into a text box but nothing seems to work. If I go to the php page it prints:

 

var1=cheese

 

So I know the php side is OK... just no luck with the flash import. I'd rather not go the PHP - XML - Flash route if possible.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/195149-php-into-flash/
Share on other sites

Ah... well the flash itself isn't my problem really as I have specialized in flash but this is my first experience with PHP. I've set up the flash coding a few different ways, similiar to how I would make it read from an XML but for some reason it just won't pull the vars. I'm thinking it may have more to do with my php script rather then the flash side but who knows. My php is as follows:

 

scorecard.php?file=TEST

 

<?php

$file="'{$_GET['file']}'";

 

if($file) {

  $con = mysql_connect(".com","DB","PW");

  mysql_select_db("DB", $con);

  $sql = "SELECT UserName, Rating FROM comments WHERE UserName = '{$_GET['file']}'";

  $result = mysql_query($sql)

              or die("<b>error</b>: failed to execute query <i>$query</i>");

 

  $desiredContent = mysql_fetch_array($result);

 

  mysql_free_result($result);

 

  echo "Rating=$desiredContent[Rating]";

}

?>

 

My Flash is as so:

 

Main Stage Contains a Movie Clip which Contains a Dynamic Text Box called Ratings

 

onClipEvent (load) {

loadVariables("http://www.dyno-charts.com/scorecard.php?file=TEST", this, "GET");

}

 

also tried

 

onClipEvent (load) {

Rating = new LoadVars();

Rating.onLoad = handleLoad;

Rating.load("http://www.dyno-charts.com/scorecard.php?file=TEST",this,"GET");

function handleLoad(success) {

if (sucess) {

//news_txt.htmlText = this.siteNews;

textbox.htmlText = this.scorecard;

} else {

textbox.htmlText = "<b>file not found</b>";

}

}

}

 

this one prints 'file not found' in the dyn text.

 

 

Any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/195149-php-into-flash/#findComment-1025798
Share on other sites

first of all create a function: newfunction= new LoadVars;

then do this.

newfunction.sendAndLoad("yourphpfile.php",newfunction,"GET");

In your php file you should echo status="ok"

and then in flash if ( newfunction.status="ok") {

whatever you like.}

for any further questions tell me.

php mistake:

WHERE file = '" . $_GET['file'] . "'

Link to comment
https://forums.phpfreaks.com/topic/195149-php-into-flash/#findComment-1025895
Share on other sites

Thanks for the reply ... you said to change:

 

WHERE UserName = '".$_GET['file']."'

 

to

 

WHERE file = '".$_GET['file']."'

 

but doesn't WHERE xxxx need to be a column in my data base? So where column user name is equal to the GET statement. Since I am passing along the user name in the previous page ...scorecard.php?file=TEST

Link to comment
https://forums.phpfreaks.com/topic/195149-php-into-flash/#findComment-1027175
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.