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.

Too many connections in server MySQL

Help for those learning Tcl or writing their own scripts.
Post Reply
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Too many connections in server MySQL

Post by neoclust »

Hello I tried to use mysql for storing data, but I encountered this problem
Tcl error [Channel:check]: mysql::connect/db server: Trop de connections
This is code

Code: Select all

bind pubm - * Word:check
proc Word:check {nick host hand chan text} {
	if {![channel get $chan badword]} { return 0 }
	if {[isop $nick]} {return 0}
	if {[matchattr $hand o|o $chan]} { return 0 }
	set conx [getConnection]
	set sqltext [::mysql::escape "SELECT * FROM ExceptWord where '$text' LIKE Mot"]
	set wordcheck [mysqlsel $conx $sqltext]
	if {$wordcheck  > 0} {putlog "$text existant" ; return 0}
	set sqltext [::mysql::escape "SELECT * FROM ExceptWord where '$text' LIKE Badword"]
	set Badwordcheck [mysqlsel $conx $sqltext]
	if {$Badwordcheck  > 0} {
		set why [mysqlsel $conx "SELECT Raison FROM BadWord WHERE '$text' LIKE Badword"]
		if {[llength $why] > 0} {
			set ban "*!*[string range $host [string first @ $host] e]"
			putserv "PRIVMSG X :ban $chan $ban 5 75 [lindex $why 0]"
			mysql::close $conx
		}
		return 0
	}
}
there must be a way to close the open connection thanks
User avatar
DarkRaptor
Voice
Posts: 36
Joined: Sat Apr 15, 2006 2:39 am
Location: Trois-Rivières, Qc

Post by DarkRaptor »

Hi,

Your code close the connection only if llenght $why is greater than 0. I suggest put mysql::close just before the last close-brace.
DarkRaptor @ irc.undernet.org
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Post by neoclust »

I have placed after return and the same message
User avatar
DarkRaptor
Voice
Posts: 36
Joined: Sat Apr 15, 2006 2:39 am
Location: Trois-Rivières, Qc

Post by DarkRaptor »

Code: Select all

bind pubm - * Word:check 
proc Word:check {nick host hand chan text} { 
   if {![channel get $chan badword]} { return 0 } 
   if {[isop $nick]} {return 0} 
   if {[matchattr $hand o|o $chan]} { return 0 } 
   set conx [getConnection] 
   set sqltext [::mysql::escape "SELECT * FROM ExceptWord where '$text' LIKE Mot"] 
   set wordcheck [mysqlsel $conx $sqltext] 
   if {$wordcheck  > 0} {putlog "$text existant" ; return 0} 
   set sqltext [::mysql::escape "SELECT * FROM ExceptWord where '$text' LIKE Badword"] 
   set Badwordcheck [mysqlsel $conx $sqltext] 
   if {$Badwordcheck  > 0} { 
      set why [mysqlsel $conx "SELECT Raison FROM BadWord WHERE '$text' LIKE Badword"] 
      if {[llength $why] > 0} { 
         set ban "*!*[string range $host [string first @ $host] e]" 
         putserv "PRIVMSG X :ban $chan $ban 5 75 [lindex $why 0]" 
      } 
      return 0 
   }
   # here
   mysql::close $conx
   #  
}
DarkRaptor @ irc.undernet.org
Post Reply