G'day,

This USED to work, then all of a sudden for no apparent reason it has
suddenly decided not to: 
if I change the code thus:

if(*row1[2] == 'l')
{
   ;
}
else if(*row1[2] == 'e')

It completes, but of course this isn't any good.

Is there something fundamentally wrong with using the same connection
for more than one 'cursor'? I understood that mysq_store_result()
simply writes the result set to a 2D character array. T4 there
should'nt be a problem.

-----------------
static MYSQL_RES *res1, *res2;
static MYSQL mysql;
static MYSQL_ROW row1, row2;
static char theSql[250];

static void slct_opt(void)
{
        char theHtml1[] =
        "\n<tr>\n <td class=\"body\">%s</td>"
        "\n <td class=\"body\">";
        
        sprintf(theSql, 
        "SELECT oc.id, ot.id, oc.i_type, oc.i_prefix, oc.cls_txt,
oc.o_name,"
        " ot.o_type, oc.i_len FROM optn_cls oc, optn_type ot"
        " WHERE oc.id = ot.ocls_id AND ot.type_id = %s"
        " GROUP BY ot.ocls_id ORDER BY ot.disp_ord", lstg_type);
        
        mysql_query(&mysql, theSql);
        res1 = mysql_store_result(&mysql); 
        if(res1)
        {
                while((row1 = mysql_fetch_row(res1)))
                {
                        printf(theHtml1, row1[4]);
                        if(*row1[2] == 'l')
                        {
                                sprintf(theSql, 
                                "SELECT so_val, so_text FROM slct_optns
WHERE otype_id = %s"
                                " AND so_val > 0 ORDER BY so_val",
row1[1]);
                                mysql_query(&mysql, theSql);
                                res2 = mysql_store_result(&mysql);
                                if(res2)
                                {
                                        printf("<select name=\"%s\">",
row1[5]);
                                        while((row2 =
mysql_fetch_row(res2)))
                                                printf("\n<option
value=\"%s\">%s</option>", row2[0], row2[1]);
                                        printf("</select>");
                                }
                                mysql_free_result(res2);
                        }
                        else if(*row1[2] == 'e')
                        {
                                printf("&nbsp;%s&nbsp;<input
type=\"text\" name=\"%s\" maxlength=\"%s\">", row1[3], row1[5],
row1[8]); 
                        }
                }
                printf("</td>\n</tr>");
        }
        mysql_free_result(res1);
        mysql_free_result(res2);
}

Any help much appreciated....


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to