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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.