$fp = @fsockopen($serverip, $loginport, $errno, $errstr, 1);
if (!$fp)
{ echo $offline; } else { echo $online; }
@fclose($fp);
does that open a database connection?
fsockopen
-
- A semi-regular
- Posts: 24
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Tue Mar 26, 2013 11:10 am
- Vanderburg
- Former staff
- Posts: 1253
- Joined: Sat Nov 13, 2010 7:27 am
- Location: Dallas, TX
Re: fsockopen
That simply tests to see if a connection can be made (And suppresses any error that might be generated in the process). If you're doing it procedurally, you will want to look up mysql_connect(), or if using objects, mysqli().
Re: fsockopen
so if that is sent enough times, it can cause mysql to have too many connections?
- Vanderburg
- Former staff
- Posts: 1253
- Joined: Sat Nov 13, 2010 7:27 am
- Location: Dallas, TX
Re: fsockopen
If you don't close the connection fast enough, yes, but the scripts are usually run so quickly that it takes these being run in quite close succession to be able to hit that number.
Re: fsockopen
so for the code i posted. does it even close the connection? cause after i removed it, my server no longer gets too many connections
- Vanderburg
- Former staff
- Posts: 1253
- Joined: Sat Nov 13, 2010 7:27 am
- Location: Dallas, TX
Re: fsockopen
Yes, fclose() closes that connection, but if I understand correct, you have an it would actually open two connections, one for the script and the script opening one with fsockopen.