弑天下
char sql[1024]= "insert into list values(?)";char value[]= "192.168.1.1";MYSQL_STMT* stmt ;MYSQL_BIND bind[1];unsigned long val_len ;// mysql is MYSQL* mysql mysql_init(mysql);stmt = mysql_stmt_init(mysql);if(!stmt){ //error}if(mysql_stmt_prepare(stmt,sql, strlen(sql)) ){ // error}// bind valuememset(bind,0,sizeof(bind));bind[0].buffer_type=MYSQL_TYPE_STRING ;bind[0].buffer = (char*)value ;bind[0].length = &val_len ;bind[0].buffer_length = strlen(value);bind[0].is_null = 0 ;bind[0].is_error = 0 ;val_len = strlen(value);mysql_stmt_bind_param(stmt,bind);// execute if(mysql_stmt_execute(stmt) ){ //error}// close mysql_stmtmysql_stmt_close(stmt) ;