| View previous topic :: View next topic |
| Author |
Message |
err0r Voice
Joined: 21 Apr 2012 Posts: 6
|
Posted: Thu May 10, 2012 5:25 pm Post subject: If data exists , skip adding data |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri May 11, 2012 12:21 am Post subject: |
|
|
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 |
|
 |
err0r Voice
Joined: 21 Apr 2012 Posts: 6
|
Posted: Fri May 11, 2012 2:36 am Post subject: |
|
|
moreresult produces errors using mysql.mod  |
|
| Back to top |
|
 |
|
|
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
|
|