[MySQL] Not fetching all groups
#1

So I tried to make something that would fetch all groups and load them, however it does not.
It does not throw any errors with this either btw. It just doesnt load them.
Any reason this is so?

pawn Код:
stock loadGroups()
{
    new groupQuery[400];
    format(groupQuery, sizeof(groupQuery), "SELECT * FROM `groups`"); //Format the query, insert the information in again
    mysql_query(groupQuery); //Run the query

    mysql_store_result(); //Store the result

    new fetchVal[100]; //A array to hold the data were going to get

    while(mysql_fetch_row(groupQuery, "|")) //Loop through the columns
    {
        for(new xf = 0; xf < MAX_GROUPS; xf++)
        {
            mysql_fetch_field("GroupID", fetchVal); //Fetch data from the column 'pAdmin' and save it to 'fetchVal'
            GroupInfo[xf][GroupID] = strval(fetchVal); //Set the variable equal to value of the fetch.

            mysql_fetch_field("GroupName", fetchVal);
            GroupInfo[xf][GroupName] = strval(fetchVal);

            mysql_fetch_field("Enabled", fetchVal);
            GroupInfo[xf][Enabled] = strval(fetchVal);

            mysql_fetch_field("MOTD", fetchVal);
            GroupInfo[xf][MOTD] = strval(fetchVal);
        }
    }
    mysql_free_result(); //Free the result
    return 1;
}
And yes this is a edit of my player loading system that does work right.
Reply
#2

Okay so I got it to load the groups, but its not loading the data from the groups such as the name.
This is what I changed it to.
pawn Код:
stock loadGroups()
{
    new groupQuery[400];
    format(groupQuery, sizeof(groupQuery), "SELECT * FROM `groups`"); //Format the query, insert the information in again
    mysql_query(groupQuery); //Run the query

    mysql_store_result(); //Store the result

    new fetchVal[100], x; //A array to hold the data were going to get

    while(mysql_fetch_row(groupQuery)) //Loop through the columns
    {
            mysql_fetch_field("GroupID", fetchVal); //Fetch data from the column 'pAdmin' and save it to 'fetchVal'
            x = strval(fetchVal);

            mysql_fetch_field("GroupName", fetchVal);
            GroupInfo[x][GroupName] = strval(fetchVal);

            mysql_fetch_field("Enabled", fetchVal);
            GroupInfo[x][Enabled] = strval(fetchVal);

            mysql_fetch_field("MOTD", fetchVal);
            GroupInfo[x][MOTD] = strval(fetchVal);
    }
    mysql_free_result(); //Free the result
    return 1;
}
Reply
#3

I guess Nevermind, this works now, I changed the code to this and it works perfectly!

pawn Код:
stock loadGroups()
{
    new groupQuery[400];
    format(groupQuery, sizeof(groupQuery), "SELECT * FROM `groups`"); //Format the query, insert the information in again
    mysql_query(groupQuery); //Run the query

    mysql_store_result(); //Store the result

    new fetchVal[100], x; //A array to hold the data were going to get

    while(mysql_fetch_row(groupQuery)) //Loop through the columns
    {
            mysql_fetch_field("GroupID", fetchVal); //Fetch data from the column 'pAdmin' and save it to 'fetchVal'
            x = strval(fetchVal);

            mysql_fetch_field("GroupName", GroupInfo[x][GroupName]);

            mysql_fetch_field("Enabled", fetchVal);
            GroupInfo[x][Enabled] = strval(fetchVal);

            mysql_fetch_field("MOTD", GroupInfo[x][MOTD]);
    }
    mysql_free_result(); //Free the result
    return 1;
}
This thread can be closed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)