Connecting to a MySql database

Forex Trader
Forex Trader  
Hi there. Hoping for some assistance with an EA and connecting to a mysql db.

I'm connecting at present using the libmysql.dll and some code found on MT4 forums (see below). What I'm having a nightmare with is returning and viewing the result set from a simple select query. I can update the mysql db via insert and append queries without any problems. The code I've found is as below. If anyone can help with an example of returning results from a simple select query I'd be most grateful. Obviously this is possible, I just can't get my head around the declarations in the dll needed to get it to work.

Many thanks.

#import "libmysql.dll"
int mysql_init(int db);
int mysql_errno(int TMYSQL);
int mysql_real_connect(int TMYSQL, string host, string user, string password, 
                       string DB,int port,int socket,int clientflag);
int mysql_real_query(int TMSQL, string query, int length);
void mysql_close(int TMSQL);

int mysql;

int start()

   mysql = mysql_init(mysql);
   if(mysql != 0) 
       Print("allocated ", mysql);
   string host = "localhost";
   string user = "testuser";
   string password = "password";
   string DB = "test";
   int clientflag = 0;
   int port = 3306;
   string socket = "";
   int res = mysql_real_connect(mysql,host,user,password,DB,port,socket,clientflag);
   int err = GetLastError();
   if(res == mysql) 
       Print("error=", mysql, " ", mysql_errno(mysql), " ");

   string query = "";
   int length = 0;
   query = "select * from MyTable";
   length = StringLen(query);
   mysql_real_query(mysql, query, length);

   int myerr = mysql_errno(mysql);
   if(myerr > 0)


Forex Trader
Forex Trader  
Take a look at

But I don't think EA's allow pointers like MYSQL *mysql;

Maybe you can put the pointer code in the dll, and the while loop in the sample script (at the bottom) in the EA code?
Forex Trader
Forex Trader  
 // php sample

 $sql = "SELECT time, ... "; 
 $res = mysql_query($sql, $link);
 while ($row = mysql_fetch_assoc($res))
    echo $row["time"];