I am trying to make a gtk application using gtk3 that uses data from a mysql database.
Here is the code that has a problem
GType* types = (GType*) malloc(num_fields * sizeof(G_TYPE_STRING));
    for(i = 0; i < num_fields; i++) {
        types[i] = G_TYPE_STRING;
    }
    store = gtk_list_store_newv(num_fields, types);
    b=0;
    while ((row = mysql_fetch_row(result)))
    {
        if (b==0) b=1;
        else gtk_list_store_append (store, &iter1);
        for(i = 0; i < num_fields; i++)
        {
            if (i == 0) while((field = mysql_fetch_field(result))!=NULL) mdata[i]=field->name;
            else 
            {
                GValue val = G_VALUE_INIT;
                g_value_init(&val, G_TYPE_STRING);
                g_value_set_string (&val,row[i]);
                gtk_list_store_set_value (store, &iter1,i-1,&val);
            }           
        }
    }
When I try to run the programm I see this error :
Gtk-CRITICAL **: gtk_list_store_set_value: assertion `iter_is_valid (iter, list_store)' failed
Does anybody have an idea how to fix the problem?
Because I am new to stackoverflow if there are some more data I need to post or the title is not good please comment.
 
    