Hi, I USE THIS FUNCTION TO INSERT VALUES TO DIFFERENT VALUES OF MY DATABASE..
void InsertValues(const string &tableName, const string &values) { char ValuesToStore[255]; long datasize; char *EncodedData; char *query; strcpy(ValuesToStore, values.c_str()); EncodedData = new char[strlen(ValuesToStore)*2 + 1]; datasize = mysql_real_escape_string(conn, EncodedData, ValuesToStore, strlen(ValuesToStore)); query = new char[datasize+255]; sprintf(query, "INSERT INTO %s %s VALUES %s", tableName.c_str(), (lookup[tableName.c_str()]).c_str(), EncodedData); mysql_real_query(conn, query, strlen(query)+255); // if the insertion involves an auto-incremented attribute, // the following line displays the value of that attribute. cout << tableName << " ID inserted = " << mysql_insert_id(conn) << endl; cout<<query; delete [] EncodedData; delete [] query; return; } NOW WHEN I CALL THIS FUNCTION IN MAIN TO INSERT VALUES LIKE, InsertValues("comm_protos", "(AwaterKent, 56)"); InsertValues("sensor", "(1, 1, 0, 0, 0, 3, 0)"); InsertValues("map_sensor_platform", "(1, 1)"); Only the first InsertValues doesnt work, It is unable to understand the string constant 'AwaterKent' When I print out the query in InsertValues it reads as INSERT INTO comm_protos (name, datarate) VALUES (AtwaterKent, 56)Values inserted into 'comm_protos' I changed to this and none of these works as well: InsertValues("comm_protos", "('AtwaterKent', 56)"); The query prints out as INSERT INTO comm_protos (name, datarate) VALUES (\'AtwaterKent\', 56)Values inserted into 'comm_protos' When I tried this, InsertValues("comm_protos", "(\'AtwaterKent\', 56)"); The query printed as: INSERT INTO comm_protos (name, datarate) VALUES (\'AtwaterKent\', 56)Values inserted into 'comm_protos' PLEASE LET ME KNOW HOW I NEED TO PASS THE STRING CONSTANT OR IF I NEED TO MAKE ANY CHANGE IN MY INSERTVALUES FUNCTION.. THANKS A LOT, SHIV __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]