Flash load variable from php/mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Flash load variable from php/mysql

Post by amir »

Hello I have a problem: I have a database(mysql) with the following fields:
pdfPath, descrizione, data_creazione
I want to display them into a flash file.
Now my php file called list.php (which collect the information from my database) is the following:

Code: Select all

<?php
         include_once '../library/config.php';
         include_once '../library/opendb.php';

       
    $query =mysql_query("SELECT * FROM `$table` ORDER BY `data_creazione`DESC ");

        $cant=0 ;
        while($row=mysql_fetch_array($query)){
           echo "$cant=$row[pdfPath]&$cant=$row[data_creazione]&$cant=$row[descrizione]";
            $cant++;
        }
        echo "cant=$cant";
?>
My flash file has 3 input dynamic text (to display the database)called data_creazione, testo, titolo
and I put an actionscript code to call the php file into my flash file here it is:

Code: Select all

myData = new LoadVars()
       
        myData.sendAndLoad("www.ilgertt.it/mazza/cms/list.php",myData,"POST");
       myData.onLoad = function(succes){
           if(succes){
                for(var i=0; i<this.cant; i++){
                   data_creazione.text = this.data_creazione
                testo.text = this.descrizione
              titolo.text = this.pdfPath
                }
           } else trace("Error loading data")
      }
everything is in one fotogramma: the input dynamic text and the actionscript code.

Can anyone be so kind to tell me why this code do not work?
I really cant' understand why it does not work. the output is completely white..
Thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Call the PHP script from a browser and see if the variables are being outputted as you'd expect. If they are, then it's a Flash problem. If they're not, fix them.
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Thanks for reply

When I use my original code , I m talking about PHP I get the output that I expected,,,,Using though my Code...its when I called my flash file that I don't see the output...
Here is my flash code.... in order to use the php file tested successfully.

[syntax="actionscript"]myData = new LoadVars()
       
        myData.sendAndLoad("www.ilger.it/mazzali/cms/list.php",myData,"POST")
        myData.onLoad = function(succes){
            if(succes){
                for(var i=0; i<this.cant; i++){
                    titolo.text = this["Titolo"+i];
                    data_creazione.text = this["Data"+i];
                   testo.text =this["Testo"+i];
                }
            } else trace("Error loading data")
        }

Sorry but for understanding I 'll have to send flash code with PHP code.

Thanks


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

http://www.ilger.it/mazzali/cms/list.php returns a blank page. If you're trying to load variables from that location then there's something wrong with it.

If you're sure that part of it is working then I suggest you ask about the Flash side of the code on a Flash forum.
Post Reply