First, I would like to say I've been lurking this site for years now, and I appreciate all that you've done to help me with C\C++.
The real issue I'm having, is I have made a program in windows that parses a yaml file, then queries a SQL database with the parsed info, and it worked fine. So I ported it over to linux, which appeared to have worked, save one problem. Whenever I test the program I get a Error 2005 saying it cannot find the host name. I've tried forcing the use of TCP, and still no avail. I've tried multiple databases, and the odd part is this works fine on windows, so if someone can shed light on the issue.
The error is specifically: Error: 2005: Unknown MySQL server host '#.#.#.#' (0)
Note: the #'s are just to censor the actual IP address.
I'm unsure what I'm doing wrong, and would like some help. My code is below.
int openConnection( char *name, char *password, char *ip, char *port, char *db )
{
printf("Opening SQL Connection...\n");
conn = mysql_init(NULL);
if (conn == NULL)
{
printf("Error: %u: %s\n", mysql_errno(conn), mysql_error(conn));
return 1;
}
if (mysql_real_connect(conn,
ip,
name,
password,
db,
(int)port,
NULL, 0) == NULL)
{
printf("Error: %u: %s\n", mysql_errno(conn), mysql_error(conn));
return 2;
}
return 0;
}