0

I'm trying to do the following:

  1. get username typed into the userField
  2. make a SEARCH mysql_query with the username as a variable

I'm having a hard time getting past phase 2 since mysql_query takes a const char* as the query string, and I can only get username as char* or wchar_t*

I'm also compiling in unicode.

My code for now:

void mysql_connect(HWND hLoginWnd) {

MYSQL *con, mysql;
MYSQL_RES *res;
mysql_init(&mysql);

mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "utf8");

mysql_real_connect(&mysql, "localhost", "root", "", "treenitaulu", 3306, NULL, 0);

char name[512], pass[512];
int lenUser = SendMessage(userField, WM_GETTEXT, 512, (LPARAM)name);
int lenPass = SendMessage(passField, WM_GETTEXT, 512, (LPARAM)pass);

if(lenUser > 0 && lenPass > 0) {

    std::string query = "SELECT pass FROM users WHERE name='" + std::string(name) + "'";

    mysql_query(&mysql, query.c_str());

}

}

What should I do?

2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
0

I don't understand -- what does line 19 have to do with username? At line 19 the contents of query already contains the user name.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.