Jump to content

repeating data


Kingy

Recommended Posts

ok this is hard to explain so i'll try to do it best i can...

 

when a user connects to irc my php bot will update the mysql database and set online to 1, likewise when someone disconnects the bot will set online to 0. Ok simple i have got that sorted....

 

But occasionally the bot will ping out and the when it finally reconnects some people have left, others have joined etc etc leaving there database online row all wrong.

 

What i'm trying to do is return the names list.. I can do this by going //NAMES # and it'll return the names on a single line

User1 User2 User3

 

heres my code so far....

 

<?php
  $opsreplace = array(":", "+", "%", "@", "&", "~"); // replacing irc op symbols
  $users = str_replace($opsreplace, "", $names[5]);
  $userlist = split(" ", $users); // splits the single line (users) into an array
  $syncselect = mysql_query("SELECT * FROM usersonline WHERE online='1'") or die(mysql_error());
  while($userow = mysql_fetch_array($syncselect)) {
    foreach($userlist as $user) {
      $dbuser = $userow['username'];
      if("$dbuser" == "$user") {
        echo "Online: $dbuser";
      } else {
        echo "Offline: $dbuser";
      }
    }
  } // want it to go through the users online and tell me which are still on the irc and which arn't anymore
?>

 

This code so far works pretty good, it will tell me who is still online but when it comes to telling me who is offline, again it does tell me, but it also repeats itself a fair amount.. Heres an example

 

NB:

USER 1 is on the IRC

USER 2 is not

USER 3 is on the IRC

 

Offline: User1

Offline: User1

Online: User1

Offline: User1

Offline: User2

Offline: User2

Offline: User2

Offline: User2

Offline: User3

Online: User3

Offline: User3

Offline: User3

Link to comment
Share on other sites

nope i still get the same repeating over and over again..

 

i think the reason why its repeat is because

 

if useronline = user1

user1 online

user2 offline

user3 offline

 

if useronline = user2

user2 online

user1 offline

user3 offline

 

so if one user is online then the other 2 users are offline

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.