I'm trying to build a queue processor which grabs tasks jobs from mysql and I need the mysql connector variable to be global, because I need to use it in multiple functions. Here is the code:
...
MYSQL *connect;
...
int main(int argc, char *argv[]) {
...
connect = mysql_init(NULL);
if (connect == NULL) { do something and end }
mysql_real_connect(connect, "127.0.0.1", "username", "password" , "database", 0, 0, 0);
...
return 0;
}
Whatever I try I get en error when calling the mysql_real_connect function. Please help!
Maybe the compiler is getting connect
confused with another variable or function name (like socket connect
). Try a different variable name - should have produced a warning though.