-
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.
-
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.
-
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?
-
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.
-
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:
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 09:43 AM.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|