Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP and Flash

Explorer ,
May 25, 2007 May 25, 2007
Hi,

I hope someone can help me with this. I try to make a start using PHP in Flash.
I have a basic problem using PHP and MySQL in Flash doing this the first time.
I want to show the text of just one record in Flash.
The database is on my testing computer.

The PHP code I use I borrowed from something else I created with Dreamweaver.
When I test the PHP code in Safari it shows the text I expect. With or without urlencode.

The Flash path to the PHP document code is probably correct.
However when I test the movie it displays: undefined.

Any help will be much appreciated.
Jos

Here is the code:

PHP

<?php
$hostname_cnNormaal = "localhost";
$database_cnNormaal = "portfoliosite";
$username_cnNormaal = "portfolioadmin";
$password_cnNormaal = "waddeneiland";
$cnNormaal = mysql_pconnect($hostname_cnNormaal, $username_cnNormaal, $password_cnNormaal);
?>
<?php
mysql_select_db($database_cnNormaal, $cnNormaal);
$query_rsHome = "SELECT kp, tekst, beeld FROM kortetekst WHERE id = 2";
$rsHome = mysql_query($query_rsHome, $cnNormaal) or die(mysql_error());
$row_rsHome = mysql_fetch_assoc($rsHome);
?>
<?php $dezeTekst = $row_rsHome['tekst'];
echo $dezeTekst;
?>

Actionscript

var txtDisplay:TextFormat = new TextFormat();
txtDisplay.font = "Arial,Helvetica,_sansserif";
dataBase_txt.setNewTextFormat(txtDisplay);
dataBase_txt.autoSize = "left";

var getJosText:LoadVars = new LoadVars();

getJosText.load(" http://localhost/phpflash/naarFlashTest.php");
getJosText.onLoad = function() {
dataBase_txt.text = this[$dezeTekst];
};
TOPICS
Server side applications
303
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2007 May 25, 2007
arnhemcs wrote:
> I hope someone can help me with this. I try to make a start using PHP in Flash.

This question is probably more appropriate to the ActionScript forum,
but the answer, as always, lies in your code.

The following section of your PHP code is wrong. Change this

> <?php $dezeTekst = $row_rsHome['tekst'];
> echo $dezeTekst;
> ?>

To this:

<?php $dezeTekst = $row_rsHome['tekst'];
echo 'tekst='.urlencode($dezeTekst);
?>

You need to send Flash a name/value pair, with the value urlencoded.

In your ActionScript change this section:

> getJosText.load(" http://localhost/phpflash/naarFlashTest.php");
> getJosText.onLoad = function() {
> dataBase_txt.text = this[$dezeTekst];
> };

to this:

getJosText.sendAndLoad(" http://localhost/phpflash/naarFlashTest.php?ck="
+ new Date().getTime(), getJosText);
getJosText.onLoad = function() {
dataBase_txt.text = this.tekst;
};

ActionScript has no knowledge of your PHP variables. The name of the
name/value pair is what identifies the value loaded by LoadVars.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2007 May 25, 2007
Thanks again David Powers. Now it works. I learned a lot of you already. I am much obliged. I have got your book PHP5 for Flash also waiting for me. Thanks,
Jos
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 25, 2007 May 25, 2007
LATEST
arnhemcs wrote:
> Thanks again David Powers. Now it works. I learned a lot of you already. I am much obliged. I have got your book PHP5 for Flash also waiting for me. Thanks,

Glad to have been of help, Jos.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines