egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mysql update

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Mar 20, 2016 4:23 am    Post subject: mysql update Reply with quote

can anyone help me with a procname for inserting and updating values into a mysql database ?! I have tryed something but it doesnt work.

Code:

set my(host) "..."
set my(user) "...
set my(pass) "..."
set my(db)   "..."

proc mysql:do {nick} {
   global my

   set handle [::mysql::connect -host $my(host) -user $my(user) -password $my(pass) -db $my(db)]

   set check "SELECT player FROM filelist WHERE player = '[::mysql::escape $nick]'"
   if {[set channel [::mysql::sel $handle $check -list]]!=""} {set do -update} {set do -insert}; putlog "$channel $do"

   switch -exact -- $do {
      -insert {
         set query "INSERT INTO `filelist` (id, laston, player, hostname, daily, weekly, monthly, total, cps, fast, qa, qar, rounds, rpoints, teamp, teamr, teamn) VALUES ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17',NOW())"
         set result [::mysql::exec $handle $query]
         if {$result != "1"} {putlog "an error has ocurred with sql: * $result"} {putlog "executing: $query - \00304Ok."}
      }
      -update { set query "UPDATE `web_statistics` SET `manager`='[::mysql::escape $my(manager)]', `valid`='$my(valid)', `time`=NOW()  WHERE channel='$channel'"
         set result [::mysql::exec $handle $query]
         if {$result != "1"} {putlog "an error has ocurred with sql: * $result"} {putlog "executing: $query - \00304Ok."}

      }
      ::mysql::close $handle
   }
}


I encounter errors like

Tcl error: ::mysql::exec/db server: Column count doesn't match value count at row 1

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Mar 20, 2016 11:23 am    Post subject: Reply with quote

Looks to me because you have 17 Columns listed and are trying to insert 18 values.
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Mar 20, 2016 1:20 pm    Post subject: Reply with quote

Yes... forgot to reply here .. NOW() was being counted like a var to
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber