AS 2 PHP doesn't always respond to my sendAndLoad
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: PHP doesn't always respond to my sendAndLoad

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    31

    PHP doesn't always respond to my sendAndLoad

    I 'm using sendAndLoad from my swf to comunicate through php wih a server.
    2 of 3 times I get a response from the php file as expected, while 1 out of 3 I get no response (returns me "output=false").
    The same thing happens when I call the php file from my browser.
    What can I do? Repeat sendAndLoad till I get a normal responce?
    I don't think this is an elegant solution.

    On my localhost I have no problem, so maybe thiwis a problem of overloaded server or somethimg like that.

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Posts
    23
    Can you post the pertinent PHP code for review?

    It does sound like a server problem, though, if it works on your localhost without issue.

  3. #3
    Member
    Join Date
    Aug 2008
    Posts
    31
    Code:
    <?php
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                         // always modified
    header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");                          // HTTP/1.0
    // ---------------------
    // include the
    // configuration file
    // ---------------------
    include_once ('config.inc.php');
    // ---------------------
    // get variables
    // sent by flash
    // ---------------------
    $userid = $_GET['userid'];
    
    // -----------------------
    // NOW RETURN MY STUDENTS (THE ID'S STUDENTS)
    // -----------------------
    $query = "SELECT name,id FROM students WHERE userid='$userid' ORDER BY name";
    $sql = mysql_query($query,$db) or die("&output=false");
    $a = 0;
    while($row = mysql_fetch_assoc($sql))
    {
       $a++;	
    	$ec_temp="&__name$a=".$row["name"]."&__id$a=".$row["id"]  ;
    	echo($ec_temp);	
    }
    mysql_free_result($sql);
     
    
    
    ?>
    How can I check if it really is a matter of the server? And how can I correct it?

  4. #4
    Junior Member
    Join Date
    Jul 2008
    Posts
    23
    This looks like a problem with MySQL. If you look at this line:

    PHP Code:
    $sql mysql_query($query,$db) or die("&output=false"); 
    It appears that every time you get output=false, it is because the query failed for some reason. Try using this for troubleshooting purposes:

    PHP Code:
    $sql mysql_query($query,$db) or die("&output=" urlencode(mysql_error())); 
    That should give you the error message that MySQL is generating.

  5. #5
    Member
    Join Date
    Aug 2008
    Posts
    31
    jFunk, I tried your suggestion, nothing changed. It gave me 'output=false' the third time I run it and no SQL error.

    I think the php file, when it returns me 'output=false', is not executed at all.

    I tried this:
    PHP Code:
    <?php
    die();
    ?>
    I get:
    The first and the second time I run it, I got no return, blank page(as expected, that is).
    The third time I got "output=false" (not as expected).
    Last edited by panoss; 10-08-2013 at 10:43 AM.

  6. #6
    Junior Member
    Join Date
    Jul 2008
    Posts
    23
    My only other thought is that the server response could be cached, which doesn't make much sense given your headers. I'm not sure how that would happen. To test this you can append each call with a timestamp (file.php?ts=10202044882).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com