From:             javervandrel at yahoo dot com
Operating system: Windows 2000 Server
PHP version:      5.0.5
PHP Bug Type:     Apache2 related
Bug description:  FSockOpen + MYSQLI = CRASH!

Description:
------------
I'm writing a script that checks a MYSQL database for all ports that are
currently assigned for shoutcast, then in a loop I'm opening each of those
connections, pulling the data on the stream (is it broadcasting, if so what
is the song title).  Then I'm updating that row in the DB with the
appropriate info.  The script works, but every 24 hours or sometimes less
the mysqli functions stop working, DB connections stop working, the only
way to solve this is to STOP apache, wait a few seconds then start again
(Restarting does not work, must be stop, wait, then start).  I cant find
anybody out there having similar issues at all.  I tried using PHP 4.3+,
5.0+, and now 5.1 RC1, and it still happens.  Any help is greatly
appreciated, thanks!

Reproduce code:
---------------
function sc_status($server, $port, $file) 
{
        $cont = "";
        $fp = fsockopen($server, $port, $errno, $errstr, 1);
        if (!$fp)
        {
                fclose($fp);
                return-2;
        }
        else
        {
                $com = "GET $file HTTP/1.1\r\nAccept: */*\r\nAccept-Language:
de-ch\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.0)\r\nHost:
$server:$port\r\nConnection: Keep-Alive\r\n\r\n";
                fputs($fp, $com);
                while (!feof($fp))
                {
                        $cont .= fread($fp, 500);
                }
                fclose($fp);
                $cont = substr($cont, strpos($cont, "\r\n\r\n") + 4);
        }

        fclose($fp);
        $parts = explode(',', $cont);
        return $parts;
}

include("dbopen.php");
$query="select port, name, username, id from djlist order by id DESC";
$stations=mysqli_query($chandle,$query);

echo "STARTS HERE<br><br>";

while(($temprow=mysqli_fetch_row($stations)) && ($continue != 6))
{
        $port=$temprow['0'];
        $name=$temprow['1'];
        $uname=$temprow['2'];
        $id=$temprow['3'];

        $value=sc_status('localhost', $port, '/7.html');

        $song=$value['6'];

        $online=$value['1'];

        if($song == "</body></html>")
                $online = 0;

        if($online != 0)
        {
                echo $song."<br>";
                $query="UPDATE djlist set song='".$song."', online=1 where 
id=$id";
                mysqli_query($chandle,$query);
        }
        else
        {
                $query="UPDATE djlist set online=0 where id=$id";
                mysqli_query($chandle,$query);
        }
}
mysqli_close($chandle);


Expected result:
----------------
STARTS HERE

Chamillionaire - Turn It Up
Elton John - Have Mercy On The Criminal
done

Actual result:
--------------
Unable to connect to Database.

-- 
Edit bug report at http://bugs.php.net/?id=34483&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34483&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34483&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34483&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34483&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34483&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34483&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34483&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34483&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34483&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34483&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34483&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34483&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34483&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34483&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34483&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34483&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34483&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34483&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34483&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34483&r=mysqlcfg

Reply via email to