Problem with mysql loading
#1

Okay, I have dynamic businesses that save fine etc

Here is my business load code:
pawn Код:
forward LoadBusinesses(b);
public LoadBusinesses(b)
{
    new Fields, Rows, szResult[128], szLabel[128], iIndex;

    cache_get_data(Rows, Fields, iConnectionHandle);

    switch(b)
    {
        case QUERY_LOAD_BIZS:
        {
            while(iIndex < MAX_BUSINESSES)
            {
           
                if(mysql_num_rows(iConnectionHandle) > 0)
                {
                cache_get_field_content(Rows, "ID", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bSQLID] = strval(szResult);

                cache_get_field_content(Rows, "Name", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bName] = strlen(szResult);
               
                cache_get_field_content(Rows, "SMessage", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bSMessage] = strlen(szResult);

                cache_get_field_content(Rows, "Owner", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bOwner] = strlen(szResult);

                cache_get_field_content(Rows, "Type", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bType] = strval(szResult);

                cache_get_field_content(Rows, "Stock", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bStock] = strval(szResult);

                cache_get_field_content(Rows, "Price", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bPrice] = strval(szResult);

                cache_get_field_content(Rows, "Alarm", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bAlarm] = strval(szResult);

                cache_get_field_content(Rows, "Level", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bLevel] = strval(szResult);

                cache_get_field_content(Rows, "EPay", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bEPay] = strval(szResult);

                cache_get_field_content(Rows, "Lock", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bLock] = strval(szResult);

                cache_get_field_content(Rows, "EVW", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bVW][0] = strval(szResult);

                cache_get_field_content(Rows, "IVW", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bVW][1] = strval(szResult);

                cache_get_field_content(Rows, "EInt", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bInt][0] = strval(szResult);

                cache_get_field_content(Rows, "IInt", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bInt][1] = strval(szResult);

                cache_get_field_content(Rows, "ExtX", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bEPos][0] = floatstr(szResult);

                cache_get_field_content(Rows, "ExtY", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bEPos][1] = floatstr(szResult);

                cache_get_field_content(Rows, "ExtZ", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bEPos][2] = floatstr(szResult);

                cache_get_field_content(Rows, "ExtA", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bEPos][3] = floatstr(szResult);

                cache_get_field_content(Rows, "IntX", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bIPos][0] = floatstr(szResult);

                cache_get_field_content(Rows, "IntY", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bIPos][1] = floatstr(szResult);

                cache_get_field_content(Rows, "IntZ", szResult, iConnectionHandle);
                BusinessInfo[b][bIPos][2] = floatstr(szResult);

                cache_get_field_content(Rows, "IntA", szResult, iConnectionHandle);
                BusinessInfo[iIndex][bIPos][3] = floatstr(szResult);
               
                format(szLabel, sizeof(szLabel), "%s\n\n[%s]\n[Owner: %s]\n[Status: %s]", BusinessInfo[iIndex][bName], ReturnBusinessType(iIndex), BusinessInfo[iIndex][bOwner], ReturnBusinessLockStatus(iIndex));
                BusinessInfo[iIndex][bLabel] = Create3DTextLabel(szLabel, COLOR_WHITE, BusinessInfo[iIndex][bEPos][0], BusinessInfo[iIndex][bEPos][1], BusinessInfo[iIndex][bEPos][2], 10.0, BusinessInfo[iIndex][bVW][0]);
                BusinessInfo[iIndex][bPickup] = CreatePickup(1239, 23, BusinessInfo[iIndex][bEPos][0], BusinessInfo[b][bEPos][1], BusinessInfo[iIndex][bEPos][2], BusinessInfo[iIndex][bVW][0]);

                b++;
               
                }
               
                printf("[SERVER]: %d businesses were loaded.", iIndex);
                return 1;
            }
        }
    }
    return 1;
}
Idk why, but it always loaded 0 businesses when their is businesses in the database

I have this under OnGameModeINit
mysql_function_query(iConnectionHandle, "SELECT * FROM businesses", true, "LoadBusinesses", "d", QUERY_LOAD_BIZS);
Reply
#2

Do NOT return inside a loop unless you explicitly want to break out of it. Also you forgot to increment iIndex which will result in a infinite loop if the return I just mentioned is removed.
Reply
#3

Removing the return 1 didn't fix it
Reply
#4

Read my second sentence.
Reply
#5

How do I increment it?
Reply
#6

Anyone please?
Reply
#7

Anyone? plsssssssssssssssssssssssssssss
Reply
#8

http://en.wikipedia.org/wiki/Increme...ment_operators
Reply
#9

iIndex++;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)