MySQL problem
#1

so i tried to select an integer from a column called town from a table called playerData, if it is 0, it spawns you at SF, if its 1 it spawns you at LV, if its -1, it asks you for a location to spawn.
So i created a variable called townspawn to select from the table the value, but it always select the value as 1, even it is 0 at the column, so what is the problem in the code?



Код:
	new townQuery[200];
		new townspawn = format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee);
		if(townspawn == -1)
		{
			ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", "");
			TogglePlayerSpectating(playerid, true);
			return 1;
		}
		else if(townspawn == 0)
		{
		    playerData[playerid][playerTown] = SF;
		}
		else if(townspawn == 1)
		{
	 		playerData[playerid][playerTown] = LV;
		}
Reply
#2

You are just formatting a string.The query need to be executed and then fetch result.
Reply
#3

Quote:
Originally Posted by SyS
Посмотреть сообщение
You are just formatting a string.The query need to be executed and then fetch result.
and how to do that?
Reply
#4

Which version of MySQL are you using?
Reply
#5

StrickenKid's MySQL Plugin - v2.1.1 (https://sampforum.blast.hk/showthread.php?tid=122983)
Reply
#6

pawn Код:
new townQuery[200];
        format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee);
        mysql_query(townQuery), mysql_store_result();
        if(mysql_num_rows() != 0)
        {
            mysql_fetch_row_format(townQuery);
            sscanf(townQuery, "i", townspawn);
            mysql_free_result();
        }
        switch(townspawn)
        {
            case -1:
            {
                ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", "");
                TogglePlayerSpectating(playerid, true);
            }
            case 0:
            {
                playerData[playerid][playerTown] = SF;
            }
            case 1:
            {
                playerData[playerid][playerTown] = LV;
            }
        }
Reply
#7

Quote:
Originally Posted by XHunterZ
Посмотреть сообщение
StrickenKid's MySQL Plugin - v2.1.1 (https://sampforum.blast.hk/showthread.php?tid=122983)
Why are you using a depreciated and older MySQL plugin which was last updated in 2011? Use a better and simplified verison of Blueg's MySQL
Reply
#8

Quote:
Originally Posted by biker122
Посмотреть сообщение
pawn Код:
new townQuery[200];
        format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee);
        mysql_query(townQuery), mysql_store_result();
        if(mysql_num_rows() != 0)
        {
            mysql_fetch_row_format(townQuery);
            sscanf(townQuery, "i", townspawn);
            mysql_free_result();
        }
        switch(townspawn)
        {
            case -1:
            {
                ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", "");
                TogglePlayerSpectating(playerid, true);
            }
            case 0:
            {
                playerData[playerid][playerTown] = SF;
            }
            case 1:
            {
                playerData[playerid][playerTown] = LV;
            }
        }
thank you so much ill try it +rep
Reply
#9

Quote:
Originally Posted by Debjit
Посмотреть сообщение
Why are you using a depreciated and older MySQL plugin which was last updated in 2011? Use a better and simplified verison of Blueg's MySQL
but the gamemode is huge and ill have to change all the functions of MySQL in the gamemode.
Reply
#10

error 017: undefined symbol "mysql_fetch_row_format"

should i replace it with mysql_fetch_row_data?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)