This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Help with fetching info from a dbase

Old posts that have not been replied to for several years.
Locked
R
Repec

Help with fetching info from a dbase

Post by Repec »

Hello,

I been trying to make a tcl script which can fecth info from a vbulletin dbase through a public command. But somehow the information doesnt get relayed to my irc channel.

This is what the bot says on the partyline:

[15:14] Userinfo: executing SELECT userid,posts FROM `user` WHERE username='Repec'
[15:14] test query19 (just added for testing)

And this is the script im using:

Code: Select all

load /usr/local/lib/tcl8.3/mysqltcl/libmysqltcl.so.2

#####################################
# DATABASE VARIABLES                #
#####################################
set db(host) "localhost"
set db(username) "tralala"
set db(password) "secret"
set db(database) "mydbase"
set db(socket) "/var/lib/mysql/mysql.sock"

#####################################
# CONNECT TO DATABASE               #
#####################################
set db_handle [mysqlconnect -host $db(host) -user $db(username) -password $db(password) -db $db(database) -socket $db(socket)]

#####################################
# BINDS                             #
#####################################
bind pub - !user pub_userlookup

#####################################
# CODE STARTS HERE                  #
#####################################
set app(version) "14-8-2004 4:21PM"

proc pub_userlookup { nick uhost hand chan text} {
  global db_handle

  set sUsername [lindex $text 0]
  
  set sql "SELECT userid,posts,Stros,Races,Scans,Hacks,requestsfilled FROM `user` WHERE username='$sUsername'"
  putlog "Userinfo: executing $sql"

  set result [mysqlquery $db_handle $sql]
  putlog "test $result" <-- is just for testing

   if {[set row [mysqlnext $result]] != ""} {
      set userid [lindex $row 0]
      set posts [lindex $row 1]

putserv "PRIVMSG $chan: User stats for \002$sUsername\002: \[Posts: $posts \]"
  } else {
    putserv "PRIVMSG $chan :Couldn't find userinfo"
  }
  mysqlendquery $result
}
Hope someone can tell me what I did wrong, cuz it seems it does run the query but thats about it.

Thx in advance

/Repec
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Help with fetching info from a dbase

Post by user »

Repec wrote:

Code: Select all

set row [mysqlnext $result]
don't you mean

Code: Select all

set row [mysqlnext $db_handle]
?
Have you ever read "The Manual"?
R
Repec

Post by Repec »

yeah, i figured out what i did wrong and got it working now.
Had to completely rewrite the code lol.

Thx for the answer :D
Locked