<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/16712" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2009-03-18T20:48:56-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/16712</id>

		<entry>
		<author><name><![CDATA[Yutani]]></name></author>
		<updated>2009-03-18T20:36:56-04:00</updated>

		<published>2009-03-18T20:36:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87943#p87943</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87943#p87943"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87943#p87943"><![CDATA[
Very nice! Thanks! I've managed to get it to work so I can continue programming the script.<br><br>nml375 and Sir_Fz, thanks for the effort!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10556">Yutani</a> — Wed Mar 18, 2009 8:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-18T19:29:51-04:00</updated>

		<published>2009-03-18T19:29:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87940#p87940</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87940#p87940"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87940#p87940"><![CDATA[
Now you do <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Ahh, overlooked one thing..<br>When you enclose a string using {}, you prevent variable- and command-substitutions. So unfortunately, the query is actually looking for $text rather than the content of it.<br><br>Restore that ::mysql::escape you had in your previous post for security issues, and alter the ::mysql::query command to read as below:<div class="codebox"><p>Code: </p><pre><code>set query [::mysql::query $database "SELECT * FROM `table` WHERE `field` LIKE '%${search}%"]</code></pre></div>The use of ${search} rather than $search is simply to make sure tcl does'nt try to add the last % to the variable name.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Mar 18, 2009 7:29 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Yutani]]></name></author>
		<updated>2009-03-18T19:05:36-04:00</updated>

		<published>2009-03-18T19:05:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87939#p87939</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87939#p87939"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87939#p87939"><![CDATA[
I did not know that. I do have to mention that this is my very first own creation so there could be more newb mistakes in the code. But since I'm trying to learn how to use it, your comment was very helpful!<br><br>I've done what you suggested but still there seems to be a problem.<br><div class="codebox"><p>Code: </p><pre><code>proc pub:search {nick host hand chan text} {global database prefixset text[stripcodes abcgru $text]set query[::mysql::query $database {SELECT * FROM table WHERE `field` LIKE '%$text%'}]set row[::mysql::fetch $query]set return[lindex $row 1]putquick "PRIVMSG $chan :$prefix Results: \002$return\002"# free the sql results::mysql::endquery $query}</code></pre></div>This is what I've got so far and still... when I change $text to a string, it works. And when I change the string back to $text, it doesn't work.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10556">Yutani</a> — Wed Mar 18, 2009 7:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-18T18:37:38-04:00</updated>

		<published>2009-03-18T18:37:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87938#p87938</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87938#p87938"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87938#p87938"><![CDATA[
The point is, you should not use "args" as an argument for your proc.<br><br>The issue at hand here, is that tcl treats "args" specially, in that it will take 0 or more arguments, and add them to a list (each argument as a separate list item). This list is then stored in args. Simply storing the value of args into a new variable will not automatically remove the list..<br><br>This is the reason why you see many "poor" scripters using code like this. Most of them using it because "it works", but they have no real clue as to why:<div class="codebox"><p>Code: </p><pre><code>proc myproc {nick host hand chan args} {set args [lindex $args 0]...}</code></pre></div>That is very bad practice, and you should instead use something like this:<div class="codebox"><p>Code: </p><pre><code>proc myproc {nick host hand chan text} {...}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Mar 18, 2009 6:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Yutani]]></name></author>
		<updated>2009-03-18T17:46:48-04:00</updated>

		<published>2009-03-18T17:46:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87936#p87936</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87936#p87936"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87936#p87936"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc pub:search {nick host hand chan args} {global database prefixset search[stripcodes abcgru $args]set search[::mysql::escape $search]set query[::mysql::query $database {SELECT * FROM `table` WHERE `field` LIKE '%$search%'}]set row[::mysql::fetch $query]...</code></pre></div>This is the piece of code including the procedure. As you can see I've changed the vars but it's still not working. Somehow I can't figure out why... Maybe it's the way I get the results from the database? Although it does seem to work so I'm a bit confused.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10556">Yutani</a> — Wed Mar 18, 2009 5:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2009-03-18T17:27:32-04:00</updated>

		<published>2009-03-18T17:27:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87935#p87935</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87935#p87935"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87935#p87935"><![CDATA[
If "args" is a parameter in your procedure, it returns a list and not a string as you were expecting. Try changing the variable name to something else.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Wed Mar 18, 2009 5:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Yutani]]></name></author>
		<updated>2009-03-18T20:48:56-04:00</updated>

		<published>2009-03-18T17:11:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87934#p87934</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87934#p87934"/>
		<title type="html"><![CDATA[[SOLVED] MySQL TCL 'LIKE' Problem]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87934#p87934"><![CDATA[
Hi here,<br><br>First of all I would like to say hi to the members of this forum. Been working with eggdrop for quite a while but I'm fairly new to working with Windrop in combination with MySQL.<br><br>Now on with my problem...<br><br>I'm trying to get a bot up and running on which you can search the database for information. To do so, I've created the following piece of code:<br><div class="codebox"><p>Code: </p><pre><code>set query [::mysql::query $database {SELECT * FROM `table` WHERE `field` LIKE '%$args%'}]</code></pre></div>$args is coming straight from the users input.<br><br>But somehow this does not seem to work. When I replace $args with a string like so:<br><div class="codebox"><p>Code: </p><pre><code>set query [::mysql::query $database {SELECT * FROM `table` WHERE `field` LIKE '%test%'}]</code></pre></div>It seems to work...<br><br>Perhaps its a small and minor fix but I can't get it to work. Is there anyone who can help me out in fixing this?<br><br>Thanks!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10556">Yutani</a> — Wed Mar 18, 2009 5:11 pm</p><hr />
]]></content>
	</entry>
	</feed>
