egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

If data exists , skip adding data

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
err0r
Voice


Joined: 21 Apr 2012
Posts: 6

PostPosted: Thu May 10, 2012 5:25 pm    Post subject: If data exists , skip adding data Reply with quote

Below is the Proc that i use...
It takes the data from a line of text, selects the data in a mysql query.
That works fine, but what i would like is, if the data exists in the database, the data is not added again.
I have tried many things but it fails

any suggestions please ?

Code:
proc check123 { nick host hand chan text} {
set text [split $text]
set nickname [lindex $text 1]
scan [string trim [lindex $text 2] {(),}] {%[^@]@%s} ident isp
set ip [string trim [lindex $text 4] {[]}]
putquick  " PRIVMSG #security NickName:\00304$nickname \00301Ident:\00304$ident \00301ISP:\00304$isp \00301User IP:\00304$ip"

set result [mysql_query "SELECT nickname , ident , isp , ip  FROM checklist where ip = '$ip' limit 6"]
putquick "PRIVMSG #security :Matches For the IP (Please Note Some IPS are Dynamic) :"
foreach item $result {
putquick "PRIVMSG #security :Record: [join $item ", "]"
}

mysql_query "INSERT INTO `checklist` ( nickname , ident , isp , ip  ) VALUES ( '[mysql_escape $nickname]' , '[mysql_escape $ident]' , '[mysql_escape $isp]' , '[mysql_escape $ip]')"
}
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri May 11, 2012 12:21 am    Post subject: Reply with quote

You can use:
Code:

if {![::mysql::moreresult $result]} {
# insert code
}

After each query don't forget to end it with mysql::endquery.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
err0r
Voice


Joined: 21 Apr 2012
Posts: 6

PostPosted: Fri May 11, 2012 2:36 am    Post subject: Reply with quote

moreresult produces errors using mysql.mod Sad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber