Code: Select all
set files [glob *pattern*]
set db [::mysql::connect parms]
foreach file $files {
set item [split $file -]
set artist [lindex $item 0]
set title [join [lrange $item 1 end]]
::mysql::exec $db "INSERT INTO the_table (`artist`, `title`, `file`) VALUES ('[::mysql::escape $artist]', '[::mysql::escape $title]', '[::mysql::escape $file]');"
}
::mysql::close $db
Code: Select all
-FredGibson- 8655 {Collective Soul} {Better Now} {/mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3}
Code: Select all
Collective Soul - Better Now
Code: Select all
proc pub_searchtwo {nick host hand chan text} {
global db
putserv "NOTICE $nick :Results for $text:"
set sqlhand [mysqlconnect -host $db(hostname) -user $db(username)
-password $db(password)]
mysqluse $sqlhand $db(database)
foreach query [mysqlsel $sqlhand "SELECT * FROM music WHERE
title LIKE '$text'" -list] {
putserv "NOTICE $nick :$query"
}
mysqlclose $sqlhand
}
Code: Select all
...
putserv "NOTICE $nick :[lindex $query 1] - [lindex $query 2]"
...
Code: Select all
proc pub_fetch {nick host hand chan text} {
global db
set sqlhand [mysqlconnect -host $db(hostname) -user $db(username)
-password $db(password)]
mysqluse $sqlhand $db(database)
foreach query [mysqlsel $sqlhand "SELECT * FROM music WHERE tracknum = '$text'"] {
putlog "$query"
putserv "NOTICE $nick :Sending you Song #[lindex $query 0] [lindex $query 1] - [lindex $query 2]"
}
mysqlclose $sqlhand
}
Code: Select all
"SELECT * FROM `music` WHERE `tracknum` = [::mysql::escape $text]"
Code: Select all
"SELECT * FROM `music` WHERE `tracknum` = [::mysql::escape $text]"
Code: Select all
Tcl error [pub_fetch]: mysqlsel/db server: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''music' WHERE 'tracknum' = 8655' at line 1