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.

problem with mysql select

Old posts that have not been replied to for several years.
Locked
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

problem with mysql select

Post by prozzerg »

I have a problem with this select row when $string includes spaces, does someone know if there is possible to have spaces in this way?

foreach query [mysqlsel $mysql(conn) "SELECT * FROM `info` where `text` = '$string'" -list]

if i have it this way it works, but then the question is wrong:
foreach query [mysqlsel $mysql(conn) "SELECT * FROM `info` where `text` = '%$string%'" -list]

and i dont want it this way;
foreach query [mysqlsel $mysql(conn) "SELECT * FROM `info` where `text` LIKE '%$string%'" -list]
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

of course it's possible $string to have spaces

what question is wrong? what do you mean? explain and post results, error messages, whatever output you might have
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

i use this one:
"SELECT * FROM `info` where `text` = '$string'"
(full command is: mysqlsel $mysql(conn) "SELECT * FROM `info` where `text` = '$string'" -list )

i set string to "hello this is a test" i get this output:
[03:54] Tcl error [pub:search]: expected integer but got "-this"
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

paste the whole script, or at least the relevant parts

I have no idea how does your pub:search proc look like
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

set mysql(host) "localhost"
set mysql(port) "3306"
set mysql(user) "user"
set mysql(pass) "pass"
set mysql(data) "infodb"
load /usr/lib/mysqltcl-2.50/libmysqltcl2.50.so
set mysql(conn) [mysqlconnect -host $mysql(host) -port $mysql(port) -user $mysql(user) -password $mysql(pass)]

proc pub:search {nick output handle chan string} {
global mysql
mysqluse $mysql(conn) $mysql(data)
foreach query [mysqlsel $mysql(conn) "SELECT * FROM `info` where `text` = '$string'" -list]
set words [split $query]
set writer [lindex $words 2]
set writerdate [lindex $words 3]
putserv "PRIVMSG $chan :That text was written by $writer on $writerdate"
}
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

Theres the code. and the error message is always with the second word, like this:
[03:54] Tcl error [pub:search]: expected integer but got "-secondword"

If i search only on one word everything works as it should.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

when that error msg appears, type:

Code: Select all

.set errorInfo
on bot's party line and paste the log here (using

Code: Select all

 tag)
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

on !search Paul Van Duk

Code: Select all

[18:32] Tcl error [pub:search]: expected integer but got "-Van"
.set errorInfo
What?  You need '.help'
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

enable .tcl and .set commands in your config - comment out the unbinds
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

well, the unbinds where already taken away, so thats not the problem, i did a .help set, this is the output

Code: Select all

 19:01 <Prozzerg> .help set
[19:01] #Prozzerg# help set
 ###  set <variable> [value]
    Changes the values of config-file settings of the bot, or, if used without
    a value parameter, shows the current value of a setting. Any config file
    setting changed with this command will be reset when the config file is
    reloaded. Here are the variables that can be modified with this command
    (note that other modules can add variables):
      botnet-nick     userfile        motd            paranoid-telnet-flood
      my-ip           telnet-banner   admin           use-telnet-banner
      temp-path       notify-newusers owner           my-hostname
      nat-ip          dcc-sanitycheck network         whois-fields
      username        version         firewall        telnet-flood
      ignore-time     dcc-flood-thr   hourly-updates  connect-timeout
      resolve-timeout dupwait-timeout require-p       keep-all-logs
      open-telnets    stealth-telnets handlen         reserved-portrange
      console         default-flags   log-time        max-logsize
      quick-logs      logfile-suffix  quiet-save      sort-users
      die-on-sighup   die-on-sigterm  remote-boots    max-dcc
      max-logs        protect-telnet  ident-timeout   share-unlinks
      allow-dk-cmds   userfile-perm   switch-logfiles-at
As you can see, no errorInfo there, if not errorInfo is in some module, maybe a module i dont have loaded?

list of loaded modules:

Code: Select all

 [19:05] #Prozzerg# modules
 Modules loaded:
   Module: console (v1.1)
   Module: notes (v2.1)
   Module: irc (v1.3)
   Module: ctcp (v1.0)
   Module: server (v1.2)
   Module: channels (v1.0)
   Module: dns (v1.0)
   Module: uptime (v1.2)
   Module: encryption (v2.1)
   Module: eggdrop (v106.15)
 End of modules list.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

errorInfo has nothing to do with eggdrop itself, that's why it's not in the help files; it's a build-in Tcl variable containing the last error traceback

and you still have your unbinds somewhere, otherwise .set would work (you are the bot's owner, aren't you? make sure your bothandle is in set owner) - in your config or in your scripts - remove those, restart the bot and try to do what I suggested above
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

i dont know whats wrong, but .set errorInfo does NOT work, no matter what i do.
this is what i get when i log in, it says that im the owner and so on.

Code: Select all

19:28 <bot> Connected to bot, running eggdrop v1.6.15
19:28 <bot>      ____                __
19:28 <bot>     / __/___ _ ___ _ ___/ /____ ___   ___
19:28 <bot>    / _/ / _ `// _ `// _  // __// _ \ / _ \
19:28 <bot>   /___/ \_, / \_, / \_,_//_/   \___// .__/
19:28 <bot>        /___/ /___/                 /_/
19:28 <bot>
19:28 <bot> Hey Prozzerg!  My name is bot and I am running eggdrop v1.6.15, on Linux 2.4.25.
19:28 <bot>
19:28 <bot> Local time is now 19:28
19:28 <bot> You are an owner of this bot. Only +n users can see this! For more info,
19:28 <bot> see .help set motd. Please edit the motd file in your bot's 'text'
19:28 <bot> directory.
19:28 <bot> Use .help for basic help.
19:28 <bot> Use .help <command> for help on a specific command.
19:28 <bot> Use .help all to get a full command list.
19:28 <bot> Use .help *somestring* to list any help texts containing "somestring".
19:28 <bot>
19:28 <bot> Have fun.
19:28 <bot>
19:28 <bot> Commands start with '.' (like '.quit' or '.help')
19:28 <bot> Everything else goes out to the party line.
19:28 <bot>
19:28 <bot> You have no messages.
19:28 <bot> *** Prozzerg joined the party line.
19:29 <bot> [19:29] die2plz - search
19:29 <bot> [19:29] Tcl error [pub:search]: expected integer but got "-Van"
19:29 <Prozzerg> .set errorInfo
19:29 <bot> What?  You need '.help'
19:30 <Prozzerg> .set owner prozzerg
19:30 <bot> What?  You need '.help'
and when i cat the bots config file:

Code: Select all

prozzerg@tux:~/eggdrop$ cat eggdrop.conf | grep unbind
#unbind dcc n tcl *dcc:tcl
#unbind dcc n set *dcc:set
# unbind dcc n simul *dcc:simul
#unbind msg - hello *msg:hello
# the bot and attempting to guess passwords. We now unbind this command by
# unbind msg - ident *msg:ident
# unbind msg - addhost *msg:addhost
and all the unbinds are comment out, and there is no unbinds in any of my scripts
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

set yourself as owner in bot's config, not on partyline

you must have the following:

Code: Select all

set owner prozzerg
in bot's config file
p
prozzerg
Voice
Posts: 8
Joined: Fri Dec 31, 2004 11:02 pm

Post by prozzerg »

so, now everything works, i found the problem. thanks for the help and sorry for my stupidness ;)
p
puffi
Voice
Posts: 25
Joined: Tue Jun 01, 2004 10:09 am

Post by puffi »

so is your sql problem solved then?

if not try WHERE '[mysqlescape $somestr]'
Locked