urgent help needed: strange problem with g_strconcat



I'm having a REALLY strange thing happen with g_strconcat. I'm using it
build up a SQL query to insert data into a database. The call works fine
until I add one more field, then g_strconcat blows up and causes a
segfault, this is BEFORE I even get a chance to make the sql query, I
can't even print out the resulting string to double-check what it looks
like. g_strconcat just blows up in my face!

Here is the code that works:

/* Contruct an SQL command from the data available in the customer
     entry dialog. This is long, but needs to be done this way.
  */
  
  sql = g_strconcat("insert into customers (customer_id, entry_date, title, last_name, first_name, \
      company, address, suite, phone, postal_code, buzzer, zone, pymt_mthd, cc_num, \
      account_code, acct_start, acct_abbr, acct_status, acct_users, acct_restrictions, \
      co_nicks, id_type, special) \
      values('", gtk_label_get_text(GTK_LABEL(lookup_widget(customers, "customer_number"))), "',\
      '",gtk_label_get_text(GTK_LABEL(lookup_widget(customers, "cust_entry_date"))), "',\
      '",gtk_entry_get_text(GTK_ENTRY(title->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "last_name_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "first_name_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_company_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_address_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_suite_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_phone_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_postal_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_buzzer_code"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_zone_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(payment->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "credit_card_no"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_account_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "acct_start_date"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "acct_abbr_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(status->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "auth_acct_users"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_restrict_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "co_alias_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_idtype_entry"))),"',\
      '",specialText,"')",0L);
  
  g_print("SQL Query: %s\n",sql);


Here is the code that segfaults even before the g_print (note the
addtion of id_req to the sql query):

/* Contruct an SQL command from the data available in the customer
     entry dialog. This is long, but needs to be done this way.
  */
  
  sql = g_strconcat("insert into customers (customer_id, entry_date, title, last_name, first_name, \
      company, address, suite, phone, postal_code, buzzer, zone, pymt_mthd, cc_num, \
      account_code, acct_start, acct_abbr, acct_status, acct_users, acct_restrictions, \
      co_nicks, id_req, id_type, special) \
      values('", gtk_label_get_text(GTK_LABEL(lookup_widget(customers, "customer_number"))), "',\
      '",gtk_label_get_text(GTK_LABEL(lookup_widget(customers, "cust_entry_date"))), "',\
      '",gtk_entry_get_text(GTK_ENTRY(title->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "last_name_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "first_name_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_company_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_address_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_suite_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_phone_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_postal_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_buzzer_code"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_zone_entry"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(payment->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "credit_card_no"))),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_account_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "acct_start_date"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "acct_abbr_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(status->entry)),"', \
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "auth_acct_users"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_restrict_entry"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "co_alias_entry"))),"',\
      '",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(customers, "cust_id_req"))),"',\
      '",gtk_entry_get_text(GTK_ENTRY(lookup_widget(customers, "cust_idtype_entry"))),"',\
      '",specialText,"')",0L);
  
  g_print("SQL Query: %s\n",sql);

Can anyone figure out what on earth is going on? Please, this is urgent.

I've also tried getting the value out of gtk_toggle_button_get_active
first, printing the value (which works) and then use that variable
instead, but the same problem occurs. I just DON'T GET IT!


-- 
 .''`.      Carl B. Constantine
: :' :     duckwing duckwing ca
`. `'    GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom
  "Claiming that your operating system is the best in the world because more
  people use it is like saying McDonalds makes the best food in the world."



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]