Jump to content

Help with mysql


Recommended Posts

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 by MrTieDye
Link to comment
Share on other sites

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 by Khab
Link to comment
Share on other sites

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 by MrTieDye
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...