server.php
Code: Select all
$file = "latest.jpg";
$sep = "gIrLsKiCkAsSiTsAySsOoNaTsHiRt";
if (ereg(".*MSIE.*",$HTTP_SERVER_VARS["HTTP_USER_AGENT"]))
{
# If IE, spit out one pic and exit
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-type: image/jpeg");
header("Content-size: " . filesize($file));
readfile($file);
}
else
{
# if not IE, give the browser a try
header("Content-Type: multipart/x-mixed-replace; boundary=$sep");
print "--$sep\n";
do {
print "Content-Type: image/jpeg\n\n";
readfile($file);
print "\n--$sep\n";
flush();
$mt = filemtime($file);
do {
sleep (1);
# we won't output the same image twice.
clearstatcache();
} while ($mt == filemtime($file));
} while (1);
}Code: Select all
<img src="server.php">What I would like to do however is have an sql statement run, if it returns rows, then push the information back to the client side.
It would be much appreciated if someone could simply show me how to modify his script to get that result. I tried changing the Content-Type to text/html and tried replicating the logic of the script using an sql statement that ran in a while(true) loop. But I couldn't get the right output to the client.php.
I think it has something to do with output buffering. I don't know???