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.

Remove {} brackets from Mysql output to chan [SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
P
Python
Voice
Posts: 2
Joined: Sun May 21, 2006 7:57 pm

Remove {} brackets from Mysql output to chan [SOLVED]

Post by Python »

Hi I'm making a script to fetch some data from my Mysql DB and putt it into a certain channel.

Im using eggdrop 1.6.17 with mysql.mod.

This is the script..

Code: Select all

proc sql_gpcs03 { nick uhost handle channel arg } {
    global sql_channel
     if { $sql_channel == $channel } {
     mysql_connect database host user password
       set servinf [list]
       set servname [mysql_query "SELECT ServName FROM cv_server_details WHERE `SID` = 3"]
       set servip [mysql_query "SELECT IP FROM cv_server_list WHERE `SID` = 3"]
       set servport [mysql_query "SELECT PORT FROM cv_server_list WHERE `SID` = 3"]
        set servmap [mysql_query "SELECT ServMap FROM cv_server_details WHERE `SID` = 3"]
        set servclientscur [mysql_query "SELECT Clients_cur FROM cv_server_details WHERE `SID` = 3"]
       set servclientsmax [mysql_query "SELECT Clients_max FROM cv_server_details WHERE `SID` = 3"]
       set servinf [linsert $servinf end $servname $servip $servport $servmap $servclientscur $servclientsmax]
       putserv "PRIVMSG $channel : $servinf"
     mysql_close
     }
}
And this is the output:

(01:50:58) (gP|Python) !gpcs03
(01:51:00) (@gP|Contagion) {{{ gP.CS.03 [NL] - aim_ak-colt2k3}} } {{137.224.240.17} } {{27035} } {{aim_ak_colt2k3} } {{5} } {{14} }

I dont want those stupid {} brackets!

Im sure there's a simple solution for this, but it can't seem to find one with the search (or in any FAQ).
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Use

Code: Select all

join
to turn the lists into strings and you should just lappend the information, there is no point in using linsert and whatnot. :)

edit: Why you use that many queries is beyond me, you should limit your queries by requesting multiple pieces of information with 1 query instead of 1 query for each piece of information.

(I prefer mysqltcl anyway)
P
Python
Voice
Posts: 2
Joined: Sun May 21, 2006 7:57 pm

Post by Python »

Problem solved thnx to Metroid..

Lock?
Post Reply