Please refer to the following link for more information:

Source: Internet
Author: User
Please refer to the following link for more information: $ userid, $ tempUPDATE. DB_NAME .. USERSETIsOnlineYWHEREUserID. $ userid; $ resu function checkOnline ($ userid, $ tempid = null)
{
$ Conn = connect ();

// When are you going? Nbsp;
// Adjust the bandwidth when the bandwidth is changed to the negative bandwidth when the traffic volume is changed
$ Stmt = "UPDATE". DB_NAME. ". user set IsOnline = 'y' WHERE UserID =". $ userid;
$ Result = query ($ stmt, $ conn );
// Info ($ stmt );
// What is the cause of the error? Nbsp;
If ($ tempid! = Null)
{
$ Stmt = "SELECT TempID FROM". DB_NAME. ". TEMPUSER WHERE

TempID = ". $ tempid;
$ Result = query ($ stmt, $ conn );
// Info ($ stmt );
// Zookeeper
If ($ row = fetch_array ($ result ))
{
$ Stmt = "UPDATE". DB_NAME. ". TEMPUSER SET

RequestTime = '". getCurrentTime ()." 'Where TempID = ". $ tempid;
$ Result = query ($ stmt, $ conn );
// Info ($ stmt );
}
// (I)? Nbsp;
Else
{
$ Stmt = "insert into". DB_NAME. ". TEMPUSER

VALUES ('". $ tempid."', '". getCurrentTime ()."')";
$ Result = query ($ stmt, $ conn );
// Info ($ stmt );
}
}

// When there are multiple threads
// Why? Nbsp;
$ Stmt = "UPDATE". DB_NAME. ". user set IsOnline = 'n' WHERE". time ()."-

Unix_timestamp (RequestTime)> ". ONLINE_DURATION." AND UserGroupID! = ". GUEST;
$ Result = query ($ stmt, $ conn );

// Draft
$ Stmt = "delete from". DB_NAME. ". tempuser where". time ()."-

Unix_timestamp (RequestTime)> ". ONLINE_DURATION;
$ Result = query ($ stmt, $ conn );
Disconnect ($ conn );
}

// Zookeeper, zookeeper, and zookeeper? Nbsp;
Function getOnlineNumber ()
{
$ Olnum = array ();
$ Conn = connect ();
$ Stmt = "select count (UserID) FROM". DB_NAME. ". user where IsOnline = 'y' AND

UserGroupID! = 4 "; // 4 u uest id
// Info ($ stmt );
$ Result = query ($ stmt, $ conn );
$ Olnum ['user'] = result ($ result, 0, "COUNT (UserID )");
$ Stmt = "select count (TempID) FROM". DB_NAME. ". TEMPUSER ";
// Info ($ stmt );
$ Result = query ($ stmt, $ conn );
If ($ row = fetch_array ($ result ))
{
$ Olnum ['guest '] = $ row ['count (TempID)'];
}
Disconnect ($ conn );
Return $ olnum; // from www.w3sky.com
}



Are you sure you want to understand onnect (), disconnect (), query (), fetch_array? Nbsp;
Dbmanager. inc. PHP

Define ("DB_NAME", "databasename ");
Define ("DB_USER", "user ");
Define ("DB_PASS", "pass ");
Define ("DB_HOST", "localhost ");

Function connect ()
{
// Echo "Connecting to Host:". HOST ."
";
$ Conn = mysql_connect (DB_HOST, DB_USER, DB_PASS );
Mysql_select_db (DB_NAME );
/*
If ($ conn)
{
Echo "Connect to database sucessfully. connection id:". $ conn ."
";
}
Else
{
Echo "Connect to database failed.
";
}
*/
Return $ conn;
}

Function pconnect ()
{
Return mysql_pconnect (DB_HOST, DB_USER, DB_PASS );
}

Function disconnect ($ conn)
{
$ Close = mysql_close ($ conn );
/*
If ($ close)
Echo "MySQL Database disconnected.
";
Else
Echo "MySQL Database disconnecting failed. Please try again.
";
*/
}

Function query ($ stmt, $ conn)
{
Return mysql_query ($ stmt, $ conn); // from www.w3sky.com
}

Function fetch_array ($ result)
{
Return mysql_fetch_array ($ result );
}

Function fetch_row ($ result)
{
Return mysql_fetch_row ($ result );
}

Function num_rows ($ result)
{
Return mysql_num_rows ($ result );
}

Function result ($ result, $ row, $ field)
{
Return mysql_result ($ result, $ row, $ field );
}


Rule has been released successfully
Rl_online.PHP
Function getOnline ()
{
If ($ userid = 2)
{
If (session_is_registered ("tempuserid "))
{
CheckOnline ($ userid, $ tempuserid );
}
}
Else
{
CheckOnline ($ userid );
}
Return getOnlineNumber ();
}

Ui has been released
Ui_online.PHP
$ Online_num = getOnline ();
Echo "why ?. $ Online_num ['user']. "". $ online_num ['guest ']. "?;

Http://www.bkjia.com/PHPjc/318891.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318891.htmlTechArticlefunctioncheckOnline ($ userid, $ tempid = null) {$ conn = connect (); // why? // Adjust the bandwidth when the bandwidth is changed to the negative bandwidth when calling $ stmt = "UPDATE". DB_NAME. ". USERSETIsOnline = 'y' WHEREUserID =". $ userid; $ resu...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.