17 Replies Latest reply on Nov 5, 2009 12:53 PM by kglad

    var not recognised by php?

    Devoteé Level 1

      Why isn't the "finco" not recognised/passed to php? I'm not getting the text results!!

       

      CODE:

      var finco = "motors01";


      XMLParser.load("www.abc.com/myfile.php"+finco, onFinish);
      function onFinish($success:Boolean, $results:Object, $xml:XML):Void {
        if ($success) {
        category.text += $results.category[0].value;
        namez.text += $results.namez[0].value;

       

       

      PHP

      $query = 'SELECT * FROM abstart';
      $results = mysql_query($query);

       

      $SomeVar = $_GET['finco'];

       

      $query = "SELECT * FROM abstart WHERE idcode = '$SomeVar'";
      $imagepath = "";
      $results = mysql_query($query);
      if($line = mysql_fetch_assoc($results)){
      header("Content-type: text/xml");
      echo '<?xml version="1.0" encoding="utf-8"?>';
      echo "<item>";

        • 1. Re: var not recognised by php?
          kglad Adobe Community Professional & MVP

          use:

           


          XMLParser.load("www.abc.com/myfile.php?"+finco, onFinish);

          • 2. Re: var not recognised by php?
            Devoteé Level 1

            Still nothing happens! NO response. The browser display the results when the php is loaded directly.

             

            I DON'T understand what's wrong here!!!

            • 3. Re: var not recognised by php?
              kglad Adobe Community Professional & MVP

              your $query string is incorrect.  use the echo function to debug.

              • 4. Re: var not recognised by php?
                Devoteé Level 1

                OK I altered the script using loadVars I could get the results. But How do I specify "category" to go in to my_dyn_txt01, "namez" to go to my_dyn_txt02, etc... Everything comea as a single line!

                 

                php:

                $query = 'SELECT * FROM dyoabc';
                $results = mysql_query($query);

                 

                $SomeVar = $finco;


                $query = "SELECT * FROM dyoabc WHERE idcode = '$SomeVar'";
                $results = mysql_query($query);
                if($line = mysql_fetch_assoc($results))
                {
                echo $line["category"];

                echo $line["namez"];

                echo $line["col1"];

                echo $line["col2"];

                echo $line["col3"];


                }

                mysql_close($link);


                ?>

                • 5. Re: var not recognised by php?
                  kglad Adobe Community Professional & MVP

                  assign different variables for those returns from your php:

                   

                  echo "category=...

                   

                  // in your flash

                   

                  whateverTF.text=yourreceiveLoadVars.category;

                  • 6. Re: var not recognised by php?
                    Devoteé Level 1

                    I can't seem to get this working!!! Could you please adjust this code to make it working?

                     

                    $query = 'SELECT * FROM dyomails';
                    $results = mysql_query($query);

                    $SomeVar = $finco;
                    $query = "SELECT * FROM dyomails WHERE identity = '$SomeVar'";
                    $results = mysql_query($query);
                    if($line = mysql_fetch_assoc($results))
                    {
                    echo "category=".$line["category"];
                    echo "namez=".$line["namez"];
                    echo "CN1=".$line["col1"];

                    }
                    mysql_close($link);

                    ?>

                     

                     

                     

                    code:

                    var senderLoad:LoadVars = new LoadVars();
                    var receiveLoad:LoadVars = new LoadVars();

                     

                    ab1.onRelease = function() {

                    senderLoad.finco = "motors1";
                    senderLoad.sendAndLoad("www.abc.com/my.php",receiveLoad);
                    gotoAndStop(5);
                    }
                    result1.text=receiveLoad.category;
                    result2.text=receiveLoad.namez;

                    }

                    • 7. Re: var not recognised by php?
                      kglad Adobe Community Professional & MVP

                      $SomeVar = $_POST['finco'];
                      $query = "SELECT * FROM dyomails WHERE identity = '".$SomeVar."'";
                      $results = mysql_query($query);
                      while($line = mysql_fetch_array($results))
                      {
                      echo "category=".$line["category"];
                      echo "namez=".$line["namez"];
                      echo "CN1=".$line["col1"];

                      }
                      mysql_close($link);

                      ?>

                       

                       

                       

                      code:

                       

                      result1.text="";

                      result2.text=""

                      var senderLoad:LoadVars = new LoadVars();
                      var receiveLoad:LoadVars = new LoadVars();

                      receiveLoad.onLoad=function(){

                      result1.text=this.category+"\n"; // make sure you have multiline textfields if there's more than 1 return
                      result2.text=this.namez+"\n";
                      // do something with this.CN1?

                      }

                       

                      ab1.onRelease = function() {

                      senderLoad.finco = "motors1";
                      senderLoad.sendAndLoad("www.abc.com/my.php",receiveLoad,"POST");
                      gotoAndStop(5);
                      }

                      1 person found this helpful
                      • 8. Re: var not recognised by php?
                        Devoteé Level 1

                        Still the category, namez, CN1 all are displaying in a single text field and the remaining text fields say 'undefined'.

                         

                        result1 text box: THEDATA1namez=THEDATA2CN1=THEDATA3

                        result2 text box: undefined

                        result3 text box: undefined

                         

                        I've used your codes here and all the boxes are multiline. Why is that? I want the data to be seperated and display in the specified box. like this.

                         

                        result1 text box: THEDATA1

                        result2 text box: THEDATA2

                        result3 text box: THEDATA3

                        • 9. Re: var not recognised by php?
                          kglad Adobe Community Professional & MVP

                          are you using a loadvars onData() method instead of an onLoad()?

                          • 10. Re: var not recognised by php?
                            Devoteé Level 1

                            result1.text="";
                            result2.text="";
                            var senderLoad:LoadVars = new LoadVars();
                            var receiveLoad:LoadVars = new LoadVars();


                            receiveLoad.onLoad=function(){
                            result1.text=this.category+"\n";
                            result2.text=this.namez+"\n";

                            }
                            ab1.onRelease = function() {

                            senderLoad.finco = "motors01";
                            senderLoad.sendAndLoad(www.abc.com/my.php",receiveLoad,"POST");
                            gotoAndStop(5);
                            }

                            • 11. Re: var not recognised by php?
                              kglad Adobe Community Professional & MVP

                              use:

                               

                              $SomeVar = $_POST['finco'];
                              $query = "SELECT * FROM dyomails WHERE identity = '".$SomeVar."'";
                              $results = mysql_query($query);
                              while($line = mysql_fetch_array($results))
                              {
                              echo $line["category"].",,";
                              echo $line["namez"].",,";
                              echo $line["col1"];

                              }
                              mysql_close($link);

                              ?>

                               

                              and in flash

                               

                              receiveLoad.onData = function(src) {
                                 var a:Array=src.split(",,");

                              result1.text=a[0];

                              result2.text=a[1];

                              // a[2]

                              };

                              • 12. Re: var not recognised by php?
                                Devoteé Level 1

                                Thanks!!!! That did the trick. YOU are a master pro. I love flash!!!!!

                                 

                                 

                                If Iam to pull an image path from the mysql and display the image here will it be like this?

                                 

                                php

                                echo $line["image"];

                                 

                                AS

                                result4.loadClip=a[4];

                                • 13. Re: var not recognised by php?
                                  kglad Adobe Community Professional & MVP

                                  no, if you're going to load into a target movieclip, say targetMC, use:

                                   

                                  targetMC.loadMovie(a[3]);  // if you use append ,, after $line['col1']

                                  1 person found this helpful
                                  • 14. Re: var not recognised by php?
                                    Devoteé Level 1

                                    Thank you!

                                     

                                    When I tried to add the rest the result was like this. Why is that? Which area should be altered to avoid this?

                                     

                                    result1 = Displayed allright
                                    result2 = Displayed allright
                                    CN1.text=CN1s data + CN2s data + CN3s data + etc...
                                    CN2.text=undefined
                                    CN3.text=undefined
                                    CN4.text=undefined
                                    CN5.text=undefined
                                    CN6.text=undefined
                                    CN7.text=undefined

                                     

                                     

                                    The Code:

                                     

                                    result1.text="";
                                    result2.text="";
                                    CN1.text="";
                                    CN2.text="";
                                    CN3.text="";
                                    CN4.text="";
                                    CN5.text="";
                                    CN6.text="";
                                    CN7.text="";

                                    image_mc.loadMovie();


                                    var senderLoad:LoadVars = new LoadVars();
                                    var receiveLoad:LoadVars = new LoadVars();
                                    receiveLoad.onData = function(src) {
                                      var a:Array=src.split(",,");
                                      result1.text=a[0];
                                      result2.text=a[1];
                                      CN1.text=a[2];
                                      CN2.text=a[3];
                                      CN3.text=a[4];
                                      CN4.text=a[5];
                                      CN5.text=a[6];
                                      CN6.text=a[7];
                                      CN7.text=a[8];

                                      image_mc.loadMovie(a[9]);
                                      };

                                    • 15. Re: var not recognised by php?
                                      kglad Adobe Community Professional & MVP

                                      the problem is in your php code.  you need to append ",," after each variable.

                                      • 16. Re: var not recognised by php?
                                        Devoteé Level 1

                                        Thanks kglad!!  That's it! Everything works fine.

                                        • 17. Re: var not recognised by php?
                                          kglad Adobe Community Professional & MVP

                                          great.

                                           

                                          and, you're welcome.