Little bit of SQL help
#1

How comes this function loads the data, but not the names correctly?

I have a business named Not Enterable Business and Enterable Business, but it loads this on the console:

Код:
[16:25:09] {FF0000}Business 1
Price $4000
Name: 78
Owner: 78
[16:25:09] {33FF33}Business 2
Price $4000
Name: 69
Owner: 78
[16:25:09] 2 businesses loaded from the MySQL Database.
Here is the function:

pawn Код:
stock LoadBusinesses()
{
    new
        Str[128],
        string[512],
        bID,
        bName[128],
        bOwner[24],
        Float:ExtX,
        Float:ExtY,
        Float:ExtZ,
        Float:IntX,
        Float:IntY,
        Float:IntZ,
        Price,
        Enterable,
        IntID;
       
    mysql_query("SELECT * FROM `Businesses`");
    mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>is[128]s[24]ffffffiii", bID, bName, bOwner, ExtX, ExtY, ExtZ, IntX, IntY, IntZ, IntID, Price, Enterable);
            BusinessPickup[bID] = CreatePickup(1272, 1, ExtX, ExtY, ExtZ, 0);
            if(Enterable == 0)
            {
                format(string, sizeof(string), "{FF0000}Business %d\nPrice $%d\nName: %d\nOwner: %d", bID, Price, bName, bOwner);
            }
            else
            {
                format(string, sizeof(string), "{33FF33}Business %d\nPrice $%d\nName: %d\nOwner: %d", bID, Price, bName, bOwner);
            }
            Create3DTextLabel(string, BLUE, ExtX, ExtY, ExtZ, 5.0, 0, 1);
            print(string);
            bTotal++;
        }
    }
    for(new i = 0; i < MAX_BUSINESS; i++)
    {
        Business[i][BusinessExteriorX] = ExtX;
        Business[i][BusinessExteriorY] = ExtY;
        Business[i][BusinessExteriorZ] = ExtZ;
        Business[i][BusinessInteriorX] = IntX;
        Business[i][BusinessInteriorY] = IntY;
        Business[i][BusinessInteriorZ] = IntZ;
        Business[i][BusinessInteriorID] = IntID;
        Business[i][BusinessPrice] = Price;
        Business[i][BusinessEnterable] = Enterable;
        format(Business[i][BusinessName], 128, "%s", bName);
        format(Business[i][BusinessOwner], 24, "%s", bOwner);
    }
    mysql_free_result();
    printf("%i businesses loaded from the MySQL Database.", bTotal);
}
All help is appreciated!
Reply


Messages In This Thread
Little bit of SQL help - by iGetty - 22.05.2012, 15:19
Re: Little bit of SQL help - by Ruben_Alonso - 22.05.2012, 15:26
Re: Little bit of SQL help - by iGetty - 22.05.2012, 15:30
Re: Little bit of SQL help - by Ruben_Alonso - 22.05.2012, 15:36
Re: Little bit of SQL help - by iGetty - 22.05.2012, 15:49

Forum Jump:


Users browsing this thread: 1 Guest(s)