12 Replies Latest reply on Mar 29, 2011 5:24 PM by kglad

    why using $_GET in a php code flash don't display the result

    jaikopd

      Why flash don't display my data query send from a php file that use the $_GET to retrive the information and run a query to display the result back to flash.

      but when I change the $_GET variable in the php file for a static value let's say (2), flash display the data that was requested in the php query..

       

      with $_GET I get in flash   undefined

      with "2"  I get in flash the data requested...

        • 1. Re: why using $_GET in a php code flash don't display the result
          kglad Adobe Community Professional & MVP

          are you posting or getting those variables in flash?

          • 2. Re: why using $_GET in a php code flash don't display the result
            jaikopd Level 1

            Not I'm no posting or getting  those variables back to flash.....  the only variable that is send back to flash is  singleBody , as a echo to be printed

             

            with     $id = $_GET['id']   I get this in flash  ReferenceError: Error #1069: Property singleBody not found on String and there is no default value. or I get undefined

             

            if a substitud  $id = $_GET['id']  for  this one   $id="2";     i get this result in flash (  white | uncommon | creature | Human  | Soldier Ally |   |  |  | 1 | Worldwake | 0 | 1 | Cyril Van Der Haegen | </a></font></u> <br /> )

             

            this the AS code I'm using to retrive and display the data back to flash:

             

            MovieClip(parent).db_mc.addEventListener(MouseEvent.CLICK, displayData);

             

            function displayData(event:MouseEvent):void{

             

            var variables:URLVariables = new URLVariables();

            var varSend:URLRequest = new URLRequest("http://localhost/Scripts/passing variables.php");

            varSend.method = URLRequestMethod.POST;

            varSend.data = variables;

            var varLoader:URLLoader = new URLLoader;

            varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

             

            varLoader.addEventListener(Event.COMPLETE, completeHandler);

             

            function completeHandler(event:Event):void{

             

              if (event.target.data.singleBody == "") {

            data_rest_txt.text = "No data coming through";

              } else {

            data_rest_txt.condenseWhite = true;

            data_rest_txt.htmlText = "" + event.target.data.singleBody;

            trace(event.target.data.singleBody);

              }

              }

             

            varLoader.load(varSend);

            }

             

             

            this is the php code that search the database and echo back to flash the result:

             

            <?php

            //So we can display the aditional data from the selected Item....

            session_start();

             

            //If flash received the data from above... them we run this code

            //if ($_POST['datarequester'] == "card_name") {

            include_once "connect_to_mysql.php";

             

            if(isset($_GET['id'])){

            $body2 = "";

            $imageBody = "";

            $id = $_GET['id'];  

            $singleBody = "";

            $sql = mysql_query("SELECT * FROM `magic_cards` WHERE id='$id' ");

             

            while($row = mysql_fetch_array($sql)){

             

            $id = $row['id'];

            $name = $row['name'];

            $color = $row["color"];

            $rare = $row["rare"];

            $type = $row["type"];

            $creature_type= $row["creature type"];

            $creature_type2= $row["creature type_2"];

            $ability_1= $row["ability_1"];

            $ability_2= $row["ability_2"];

            $ability_3= $row["ability_3"];

            $manacost= $row["manacost"];

            $set= $row["set"];

            $power= $row["power"];

            $resistence= $row["resistence"];

            $artist= $row["artist"];

            $ruling= $row["ruling"];

            $image = $row["image"];

            $imageBody .= $image;

            $body2 .= $color. " | ". $rare. " | ". $type. " | ".  $creature_type. " | ". $creature_type2. " |  ". $ability_1. " | ".  $ability_2. " | ". $ability_3. " | ". $manacost. " | ". $set. " | ". $power. " | ". $resistence. " | ". $artist. " | ".  $ruling. '</a></font></u> <br />';

             

                }

                echo "singleBody= $body2";

            //echo "imageBody= $imageBody";

                mysql_close();

                exit();

            }

            //}

            ?>

            • 3. Re: why using $_GET in a php code flash don't display the result
              kglad Adobe Community Professional & MVP

              you're posting.  use get:

               

              varSend.method = URLRequestMethod.GET;

              • 4. Re: why using $_GET in a php code flash don't display the result
                jaikopd Level 1

                I changed the method to GET... but still dosen't work..... I look the trace and I recived this:

                 

                Notice Undefined index in Web Pages Site Flash Site Scripts passing variables.php on line 11 singleBody=%20

                 

                I search the line 11 and is where $id = $_GET['id']  

                 

                Again when $id = $_GET['id'];  (dynamic value)...  is use I get this (undefined .... Notice Undefined index in Web Pages Site Flash Site Scripts passing variables.php on line 11 singleBody=%20 )

                 

                When  $id = $_GET['id'];  is changed to $id = "2"; (static value)... I get this ( white | uncommon | creature | Human | Soldier Ally | | | | 1 | Worldwake | 0 | 1 | Cyril Van Der Haegen | )  this is what I supposed to get when I use  $id = $_GET['id'];

                • 5. Re: why using $_GET in a php code flash don't display the result
                  kglad Adobe Community Professional & MVP

                  i don't see where you're assigning properties to variables.  in particular, i don't see id assigned.

                  • 6. Re: why using $_GET in a php code flash don't display the result
                    jaikopd Level 1

                    The id variable is define in the php code as $id = $_GET['id']   (this is the php code variable).... the problem as I said is that flash don't accept when I use the $_GET[''] argument in the php code;  it read it as there no variable specifid for the  $id ;  only is accepted for flash when a static value is assigned to the $id variable...

                     

                    $id = $_GET[''];     for flash this variable definition is null don't have value assigned  but if I run the php file in my localhost I get this in my browser :

                     

                                                  singleBody= white | uncommon | creature | Human | Soldier Ally | | | | 1 | Worldwake | 0 | 1 | Cyril Van Der Haegen |

                     

                    If the value is static like this:

                     

                    $id = " x ";         where x is any number is accepted for flash and display accordingly and run the php file in my localhost I recived this

                     

                                                   singleBody= white | uncommon | creature | Human | Soldier Ally | | | | 1 | Worldwake | 0 | 1 | Cyril Van Der Haegen |

                     

                                             If I publish flash with "x" value I recived this in flash

                     

                                                  white | uncommon | creature | Human | Soldier Ally | | | | 1 | Worldwake | 0 | 1 | Cyril Van Der Haegen |

                     

                                             so as you can see the diference between those is the  $_GET['']  argument...

                    • 7. Re: why using $_GET in a php code flash don't display the result
                      jaikopd Level 1

                      Why is the question so hard to answer.....?

                      • 8. Re: why using $_GET in a php code flash don't display the result
                        kglad Adobe Community Professional & MVP

                        it's not hard to answer.  it's been answered.  you're having trouble understanding.

                         

                        id is not assigned in your actionscript.

                        • 9. Re: why using $_GET in a php code flash don't display the result
                          jaikopd Level 1

                          You still don't get it.......

                           

                          is my english too bad to understand......

                           

                          please get this:  I DON'T NEED TO ASSIG ID  IN ACTIONSCRIPT ..... THE ID VALUE IS COMING FROM THE PHP FILE IF YOU CHECK THE PHP FILE I'M ASSIGNING A VALUE TO IT THAT IS $_GET['ID'];         THAT VALUES THAT IS DINAMIC IS ASSIGN IN PHP TO $id        THAT DINAMIC VALUES IS NOT ACCEPTED WHENT THE RESULT OF THE QUERY IS SEND TO FLASH THAT'S WHENT FLASH SAY IS UNDEFINED   .... BUT IF CHANGE THAT DINAMIC VALUE TO STATIC.... READ STATIC VALUE.... THEM FLASH ACCEPT THE RESULT FROM THE QUERY......

                           

                          now if my answer was answered... please explained to me as I was a baby....

                          • 10. Re: why using $_GET in a php code flash don't display the result
                            kglad Adobe Community Professional & MVP

                            if you don't think flash needs to send id to your php just where do you think $_GET['id'] is coming from?

                            • 11. Re: why using $_GET in a php code flash don't display the result
                              jaikopd Level 1

                              from this php file...   if you see this part :

                               

                              $body .= $id. '<u><font color="#00FF00"><a href="http://localhost/Scripts/passing variables.php?pid=' . $id.  '" target="_self">'.  ". ". $name . '</a></font></u> <br />';

                               

                              all this is a query from my database that render the result back to flash as a link with the variable   echo "returnBody= $body";   the passing variables.php?pid=' . $id   , store the value of the link... and that is the id I'm looking when I use this $id= $_GET['id']; 

                               

                              if the link value id is a one time 3  the $id value has to be 3, 'cos it was the value store in the link that was supposed assign it when  I use $id= $_GET['id']; when the value is assigned in the php file it render the related data from the database concerning that id

                               

                              <?php

                              session_start();

                               

                              if ($_POST['datarequester'] == "card_name") {

                              // Connect to database

                              include_once "connect_to_mysql.php";

                              $body = "";

                              $request=  $_POST['request_'];

                              $returnBody= "";

                              $sql = mysql_query("SELECT id, name, rare FROM `magic_cards` WHERE rare='$request' ");

                               

                              while($row = mysql_fetch_array($sql)){

                               

                              $id = $row["id"];

                              $name = $row["name"];

                              $body .= $id. '<u><font color="#00FF00"><a href="http://localhost/Scripts/passing variables.php?pid=' . $id.  '" target="_self">'.  ". ". $name . '</a></font></u> <br />';

                                  }

                                  echo "returnBody= $body";

                                  mysql_close();

                                  exit();

                              }

                               

                              • 12. Re: why using $_GET in a php code flash don't display the result
                                kglad Adobe Community Professional & MVP

                                ok, that php file is passing id when it calls variables.php.    that doesn't help your actionscript pass id.