Jump to content

fsockopen() and updating a database.


imod3rn

Recommended Posts

Okay guys, so i have a status checker connected to a mySql database.

Now, what i want to do is have it check the status, then update the field in the table.

 

Here is my code, please someone add or tell me how to add the update mysql thing.

 

<?php
error_reporting(0);
include '../dbc.php';
if(isset($_GET['id']))
{
        $id = intval($_GET['id']);
        //We check if the user exists
        $dn = mysql_query('select * from users where id="'.$id.'"');
       if(mysql_num_rows($dn)>0)

        {
                $dnn = mysql_fetch_array($dn);
                //We display the user datas

	$offline='<font color="red">Offline</font>';
	$online='<font color="green">Online</font>';
	$host=(htmlentities($dnn['server_ip']));
	$style=(htmlentities($dnn['style']));
	 $port=htmlentities($dnn['port']);

    $fp = fsockopen($host, 43594, $errno,$errstr, 4);
         if (!$fp){
            echo('<font color="red">Offline</font>');
         } else {
	$online=echo('<font color="green">Online</font>');
             fclose($fp);
         }

}
}
?>

 

Thanks, hope so one can help me :D

Link to comment
https://forums.phpfreaks.com/topic/250746-fsockopen-and-updating-a-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.