| View previous topic :: View next topic |
| Author |
Message |
Buffy_25 Halfop
Joined: 22 Nov 2003 Posts: 63
|
Posted: Mon Dec 19, 2005 2:47 pm Post subject: String tolower |
|
|
Hi,
I have a problem with the following code.
When a user joins and leaves after a certain period, i add (if not created yet in mysql-DB) or update his uptime in mysql-DB (if already created).
My problem is, when a person leaves (i.e. MaRkO) and he was already created as marko, then the database will create a new user in stead of updating his actual ID.
Does any one have an idea why the string tolower isn't working?
Thanks.
Buffy
| Code: |
proc userleft {nick uhost hand dest key arg} {
set fs1 [open /home/account/eggdrop/logs/timeon.txt a+]
puts $fs1 "$arg"
close $fs1
set user [lindex [split $arg] 0]
set time [join [lrange $arg 1 end]]
mysql_connect datab localhost account passw /var/lib/mysql/mysql.sock
set listuser [mysql_query "SELECT name FROM Userinfo"]
foreach a $listuser {
lappend list1 [string tolower $a]
}
if {[lsearch -exact $list1 [string tolower $user]] == -1} {
set insert_command [mysql_query "INSERT INTO Userinfo (name) VALUES ('$user')"]
set newtime [mysql_query "UPDATE Userinfo SET timeon='$time' WHERE name='$user'"]
set time [convert_online $time]
set timesec [mysql_query "UPDATE Userinfo SET timeonsec='$time' WHERE name='$user'"]
} else {
set presenttime [mysql_query "SELECT timeon FROM Userinfo WHERE name='$user'"]
set convpresenttime [convert_online $presenttime] #the convert_online is working ok !
set convuseronline [convert_online $time]
set useronline [expr $convuseronline+$convpresenttime]
set onlinetime [duration $useronline]
set newtime [mysql_query "UPDATE Userinfo SET timeon='$onlinetime' WHERE name='$user'"]
set newtime [mysql_query "UPDATE Userinfo SET timeonsec='$useronline' WHERE name='$user'"]
}
}
|
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Dec 19, 2005 4:59 pm Post subject: |
|
|
string tolower is not applied on all the $user variables in your code. Why don't you initialize it as lower case
| Code: | | set user [string tolower [lindex [split $arg] 0]] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Buffy_25 Halfop
Joined: 22 Nov 2003 Posts: 63
|
Posted: Tue Dec 20, 2005 4:23 pm Post subject: |
|
|
Hi Sir_Fz,
This could be an option, but the problem is that my variables are used kindly everywhere in my scripts, and i would prefer to avoid to modify whole my scripts.
Therefor i tried to keep my nicks as they are, but just wanted to check between the nick registered in database and the nick that left.
Is there a way that i could make it being applied to all the variables?
Thanks.
Buffy |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Dec 20, 2005 4:40 pm Post subject: |
|
|
If the variable isn't global, you can only apply string tolower inside the proc. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Buffy_25 Halfop
Joined: 22 Nov 2003 Posts: 63
|
Posted: Sat Dec 24, 2005 4:16 am Post subject: |
|
|
I found the problem Sir_Fz !
Thanks for the notice !
Buffy |
|
| Back to top |
|
 |
|