MYSQL executing multiple statements

Hi, I have the following code, which needs to execute three sql statements. The first two work and return results, but the last INSERT doesn't, any idea why?

DECLDIR int sqlInsert(char* server, char* user, char* pwd, char* db, int port, char* table, std::vector<char*> values, int numSize){
MYSQL* conn;
conn = sqlConnect(server, user, pwd, db, port);

std::string strDB(db);
std::string strTable(table);
std::string strQuery;

int queryRes = -1;
int idQueryRes;
MYSQL_RES *res;
MYSQL_ROW row;
int temp;

idQueryRes = mysql_query(conn, ("SELECT EXISTS(SELECT * FROM " + strDB + "." + strTable + ")").c_str());
res = mysql_use_result(conn);
while (row = mysql_fetch_row(res)){
temp = atoi(row[0]);
}
int disVal = sqlDisconnect(conn);
if (temp != 0){
idQueryRes = mysql_query(conn, ("SELECT MAX(id) FROM " + strDB + "." + strTable).c_str());
res = mysql_use_result(conn);
int num_fields = mysql_num_fields(res);
int rowId;
while (row = mysql_fetch_row(res)){
rowId = atoi(row[0]);
}
//Now check the row id
if (rowId != 0){
rowId++;
}
else {
rowId = 1;
}

std::string rowIdStr = std::to_string(rowId);
std::string query = "";
query += rowIdStr + ", ";
for (int i = 0; i < numSize; i++){
if (i == numSize - 1){
query += "'";
query += values[i];
query += "'";
}
else {
query += "'";
query += values[i];
query += "'";
query += ", ";
}
std::string temp = values[i];
}
query += ");";
queryRes = mysql_query(conn, ("INSERT INTO " + strDB + "." + strTable + " VALUES(" + query).c_str());
}
else {
queryRes = -1;
}
return queryRes;
}
What is the return value from the last mysql_query ?
Topic archived. No new replies allowed.