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.

If data exists , skip adding data

Help for those learning Tcl or writing their own scripts.
Post Reply
e
err0r
Voice
Posts: 6
Joined: Sat Apr 21, 2012 9:00 pm

If data exists , skip adding data

Post by err0r »

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: Select all

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]')"
}
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You can use:

Code: Select all

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.
e
err0r
Voice
Posts: 6
Joined: Sat Apr 21, 2012 9:00 pm

Post by err0r »

moreresult produces errors using mysql.mod :(
Post Reply