MrTieDye Posted May 14, 2009 Posted May 14, 2009 (edited) I am using the MYSQL udf from http://www.autoitscript.com/forum/index.php?showtopic=20814 . I can't seem to get the query to work. Here is my code...$connect = _MySQLConnect("root", "****", "auratus", "localhost") If $connect == 0 Then MsgBox(0,"","Unable to connect to database.") Exit EndIf $query = _Query($connect,"SELECT * FROM cards") MsgBox(0,"wtf",$query)When the message box pops up, it does not have anything in it. Any suggestions? By the way, I can add a record to this table no problem, so I assume everything is set up correctly. There are only two records in the table right now, but I have even tried $query = _Query($connect,"SELECT * FROM cards WHERE name = 'doug'") and still nothing.EDIT: Oddly enough, MsgBox(0,"",_CountTables($connect)) will show a 1, but MsgBox(0,"",_GetDBNames($connect)) won't show anything. Edited May 14, 2009 by MrTieDye
Khab Posted May 14, 2009 Posted May 14, 2009 (edited) I haven't used the MySQL UDF yet, but I would imagine _Query returns an array of results, so you'd need to iterate through the array to display each result, even if you only have one result being returned. Edited May 14, 2009 by Khab
MrTieDye Posted May 14, 2009 Author Posted May 14, 2009 (edited) I haven't used the MySQL UDF yet, but I would imagine _Query returns an array of results, so you'd need to iterate through the array to display each result, even if you only have one result being returned. I thought the same thing myself, but when I use MsgBox(0,"wtf",$query[1]) I get (143) : ==> Error parsing function call.: MsgBox(0,"wtf",$query[1]) MsgBox(0,"wtf",$query^ ERROR EDIT : Also happens with MsgBox(0,"wtf",$query[0]) Edited May 14, 2009 by MrTieDye
Khab Posted May 14, 2009 Posted May 14, 2009 Hmm, the sample code shows $sql = _MySQLConnect("sa","sa","mydb","mywebsite.com") $var = _Query($sql,"SELECT * FROM mytable WHERE user = 'username'") With $var While NOT .EOF FileWriteLine("c:\test.txt",.Fields("user_name").value & @CRLF) .MoveNext WEnd EndWith _MySQLEnd($sql) So what if you try $connect = _MySQLConnect("root", "****", "auratus", "localhost") If $connect == 0 Then MsgBox(0,"","Unable to connect to database.") Exit EndIf $query = _Query($connect,"SELECT * FROM cards") With $query While NOT .EOF MsgBox(0,"wtf",.Fields("name").value & @CRLF) .MoveNext WEnd EndWith And see if it at least displays the relevant name fields.
MrTieDye Posted May 14, 2009 Author Posted May 14, 2009 Thanks so much Khab. This should have been obvious to me, but I read the sample code weeks ago and forgot that it was even there. Thanks again.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now