2 variables into string

  c++, mysql, sql

what is wrong in this code ? i want insert 2 variables (username and password) but dont work i dont know why. some idea ? with only username working perfectly but with password not. There is the code

MYSQL * conn = mysql_init(NULL);

conn = mysql_real_connect(conn, "127.0.0.1", "user", "password", "AMI", 3306, NULL, 0);
if(!conn) {
wxLogMessage("failed to connect database");
}



int qstate = 0;

std::string name = "asdd";
std::string password ="asdd";
std::stringstream users;
users << "INSERT INTO users (username,password) VALUES('" << name  <<  password  << "')" ;
std::string query = users.str();
const char* q = query.c_str();
qstate = mysql_query(conn,q);

if(qstate == 0) {
wxLogMessage("succesful");}
else {
    wxLogMessage ("not succesful");}

}

Source: Windows Questions C++

LEAVE A COMMENT