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.

MySQL Update script

Old posts that have not been replied to for several years.
Locked
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

MySQL Update script

Post by cvanmeer »

I've got the following script. The idea is to put this on the end of a proc and so, count the number of times, the script has been used.

Table layout: id, commando, aantal (where aantal is the field which I want to update)

Table has 1 (test) row: id=1, commando=!test, aantal=0

Code: Select all

proc user {nick host hand chan text} {
 package require sql

 set conn [sql connect $host $user $pwd]
 set res [catch {sql selectdb $conn $db} msg]

 set output [sql query $conn "SELECT MAX(aantal) FROM nROServ WHERE commando LIKE '!test'"]
 set row [sql fetchrow $conn $output]
 set aantal $row
 putlog "$aantal"
 incr $aantal
 set omhoog [sql exec $conn "UPDATE nROServ SET aantal = '$aantal' WHERE commando LIKE '!test'"]

 sql disconnect $conn
}
But when I run the script, I get the following error:
Tcl error [user]: can't read "0": no such variable

The error might be the incr $aantal but I don't know for sure.

Could someone advice me what to do?

thx

Chrizz
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

change incr $aantal to incr aantal
c
cvanmeer
Halfop
Posts: 40
Joined: Tue Dec 02, 2003 1:00 pm
Location: The Netherlands
Contact:

Post by cvanmeer »

thx!! :D
what a simple typo can do :-?
User avatar
CrazyCat
Revered One
Posts: 1359
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

it's more than a typo, it's an important prefix :)
A
Axl

Post by Axl »

u have

Code: Select all

package require sql 
I need to write a tcl script that uses mysql too and Im guessing this is the first place to start.. where can I get this package to install on my server?

Cheers
N
Neomaster
Voice
Posts: 25
Joined: Mon Feb 23, 2004 5:24 pm

Post by Neomaster »

Axl wrote:u have

Code: Select all

package require sql 
I need to write a tcl script that uses mysql too and Im guessing this is the first place to start.. where can I get this package to install on my server?

Cheers
Yeah... where could we get it??

I have Msql , MySql , Tcl8.4 , MysqlTcl , but still missing that "sql" package...

package require sql
Locked