MYSQL problem
#1

I have never scripted with MYSQL before and we changed the gamemode to one with MYSQL. So I basically wanted to make a /checkhouse and /checkbiz to see what business and house ID is still free to create one.

But the following problems I am getting into:
- Once I do /checkhouse and then /checkbiz I will get Unknown Command and every command in the server will return it after that
- /checkbiz doesn't even works.
- Once I do /checkhouse it will return all the ID's and not a single one.

The code:
pawn Код:
#include <a_sampmysql>

if(strcmp(cmd,"/checkbiz",true) == 0)
    {
        new business[100][64];
        new sql[80];
        new row[512];
        format(sql, sizeof(sql), "SELECT COUNT(*) FROM bizz");
        samp_mysql_query(sql);
        samp_mysql_store_result();
        samp_mysql_fetch_row(row);
        totalbizz = strvalEx(row);
        samp_mysql_free_result();
        for (idx=0; idx<totalbizz; idx++)
        {
            format(sql, sizeof(sql), "SELECT * FROM bizz WHERE id=%d", idx);
            samp_mysql_query(sql);
            samp_mysql_store_result();
            if (samp_mysql_num_rows() > 0)
            {
                samp_mysql_fetch_row(row);
                split(row, business, '|');
                samp_mysql_free_result();
                Business[idx][bBuyPrice] = strvalEx(business[12]);
                new loadedbizz = 0;
                if(Business[idx][bBuyPrice] == 0)
                {
                    if(loadedbizz == 0)
                    {
                        loadedbizz = 1;
                        format(string, sizeof(string), "* Business ID %d is free!", idx);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                    }
                }
            }
        }
        return true;
    }
    if(strcmp(cmd,"/checkhouse",true) == 0)
    {
        new arrCoords[24][64];
        new sql[80], row[512];
        format(sql, sizeof(sql), "SELECT COUNT(*) FROM property");
        samp_mysql_query(sql);
        samp_mysql_store_result();
        samp_mysql_fetch_row(row);
        totalhouses = strvalEx(row);
        samp_mysql_free_result();
        for (idx=0; idx<totalhouses; idx++)
        {
            format(sql, sizeof(sql), "SELECT * FROM property WHERE id=%d", idx);
            samp_mysql_query(sql);
            samp_mysql_store_result();
            if (samp_mysql_num_rows() > 0)
            {
                samp_mysql_fetch_row(row);
                split(row, arrCoords, '|');
                samp_mysql_free_result();
                Property[idx][hValue] = strvalEx(arrCoords[9]);
                new loadedhouse = 0;
                if(Property[idx][hValue] == 0)
                {
                    if(loadedhouse == 0)
                    {
                        loadedhouse = 1;
                        format(string, sizeof(string), "* House ID %d is free!", idx);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                    }
                }
            }
        }
        return true;
    }
Does anybody have an idea how to fix it?

Aron
Reply


Messages In This Thread
MYSQL problem - by Aron_Johnson - 19.06.2011, 16:59
Re: MYSQL problem - by Aron_Johnson - 20.06.2011, 14:25
Re: MYSQL problem - by Steamator - 20.06.2011, 14:29
Re: MYSQL problem - by Alvord - 20.06.2011, 14:32
Re: MYSQL problem - by Aron_Johnson - 20.06.2011, 14:42
Re: MYSQL problem - by Alvord - 20.06.2011, 14:47
Re: MYSQL problem - by Aron_Johnson - 20.06.2011, 14:56

Forum Jump:


Users browsing this thread: 1 Guest(s)