|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-09-12 20:38 UTC] javervandrel at yahoo dot com
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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 13:00:01 2025 UTC |
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. include("dbopen.php"); <-- where's that? How do you think we can try reproducing this if we don't know the database we should apparently have created?