mIRC Home    About    Download    Register    News    Help

Print Thread
mysql comparing result with topic? (Sorta working) #213279 23/06/09 07:42 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Hi, I have mmysql working, and a way that someone can change the topic on a website, and it be reflected in the chatroom.

So, I have the following:
Code:
alias checktopic {
  var %db = $mysql_connect(host, username, password, database)
  var %sql = SELECT topic FROM sean where ID = 1
  var %res = $mysql_query(%db, %sql)
  if (%res) {
    while ($mysql_fetch_row(%res, row, $MYSQL_ASSOC)) {
      if $hget(row, topic) != $1($1).topic {
        /topic #no-nick $hget(row, topic)
      }
      else {
        halt
      }
      mysql_free %res
    }
    else {
      echo -a Error executing query: %mysql_errstr
    }
  }
}


The alias is /timermytopic 0 20 checktopic $chan

It all seams to be working correctly..
[18:53] * test-bot changes topic to 'This is my topic!!!!'

But, in another 20 seconds, it will change it again, and it will continually change it.

I am wondering how this could be done to it doesn't keep updating the topic every 20 seconds?

Thank you for any help provided,:D

Last edited by seanturner70; 23/06/09 08:04 PM.
Re: mysql comparing result with topic? (Sorta working) [Re: seanturner70] #213280 23/06/09 08:08 PM
Joined: Jul 2006
Posts: 3,833
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,833
Certainly because your syntax for the condition is false :
Quote:
if $hget(row, topic) != $1($1).topic {
You can't use $1($1).topic, this will echo '$1 $+ ).topic' (this is because of mirc parser) but anyway, use $chan($1).topic

Last edited by Wims; 23/06/09 08:09 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: mysql comparing result with topic? (Sorta work [Re: Wims] #213281 23/06/09 08:19 PM
Joined: Oct 2008
Posts: 167
S
seanturner70 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Oct 2008
Posts: 167
Thank you so much Wims, your change worked a treat.