SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/01/2019, 07:28 PM   #1
DyduShxD
Gangsta
 
DyduShxD's Avatar
 
Join Date: Jan 2013
Location: United Kingdom
Posts: 611
Reputation: 6
Thumbs up Mysql Trouble

Hello, i have changed my mysql version from R39 to R41, but ai just got mistmatch to lots of things and my server wont work.


Code:
 (14) : warning 213: tag mismatch
 (16) : warning 213: tag mismatch
 (49) : warning 213: tag mismatch
 (50) : warning 213: tag mismatch
 (54) : warning 213: tag mismatch
 (55) : warning 213: tag mismatch
 (59) : warning 213: tag mismatch
 (60) : warning 213: tag mismatch
 (64) : warning 213: tag mismatch
 (65) : warning 213: tag mismatch
 (69) : warning 213: tag mismatch
 (70) : warning 213: tag mismatch
 (74) : warning 213: tag mismatch
 (75) : warning 213: tag mismatch
 (79) : warning 213: tag mismatch
 (80) : warning 213: tag mismatch
 (84) : warning 213: tag mismatch
 (85) : warning 213: tag mismatch
 (89) : warning 213: tag mismatch
 (90) : warning 213: tag mismatch
 (94) : warning 213: tag mismatch
 (95) : warning 213: tag mismatch
 (99) : warning 213: tag mismatch
 (100) : warning 213: tag mismatch
 (104) : warning 213: tag mismatch
 (105) : warning 213: tag mismatch
 (109) : warning 213: tag mismatch
 (110) : warning 213: tag mismatch
 (114) : warning 213: tag mismatch
 (115) : warning 213: tag mismatch
 (119) : warning 213: tag mismatch
 (120) : warning 213: tag mismatch
 (124) : warning 213: tag mismatch
 (125) : warning 213: tag mismatch
 (129) : warning 213: tag mismatch
 (130) : warning 213: tag mismatch
 (134) : warning 213: tag mismatch
 (135) : warning 213: tag mismatch
 (139) : warning 213: tag mismatch
 (140) : warning 213: tag mismatch
 (144) : warning 213: tag mismatch
 (145) : warning 213: tag mismatch
 (557) : warning 213: tag mismatch
 (558) : warning 213: tag mismatch
 (756) : warning 213: tag mismatch
 (806) : warning 213: tag mismatch
 (807) : warning 213: tag mismatch
 (826) : warning 213: tag mismatch
 (827) : warning 213: tag mismatch
 (844) : warning 213: tag mismatch
 (959) : warning 213: tag mismatch
 (960) : warning 213: tag mismatch
PHP Code:
14 handle mysql_connect(mysql_hostmysql_usermysql_databasemysql_password);
16 if(handle && mysql_errno(handle) == 0)

49 to 145 - public Update(playeridtype)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
string[256];
        new 
playerName[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayerNamesizeof(playerName));
        {
            switch(
type)
            {
                case 
pLevelu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Level`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pLevel], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pAdminu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `AdminLevel`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pAdmin], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pHelperu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `HelperLevel`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pHelper], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pCashu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Cash`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pCash], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pAccountu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Account`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pAccount], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pEmailu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Email`='%e' WHERE `username`='%e'"PlayerInfo[playerid][pEmail], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pRegistredu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Registred`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pRegistred], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pTutorialu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Tutorial`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pTutorial], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pSexu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Sex`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pSex], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pAgeu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Age`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pAge], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pPhoneNumberu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `PhoneNumber`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pPhoneNumber], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pPremiumAccountu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `PremiumAccount`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pPremiumAccount], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pBannedu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Banned`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pBanned], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pWarnsu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Warns`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pWarns], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pLeaderu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Leader`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pLeader], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pMemberu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Member`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pMember], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pRanku:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Rank`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pRank], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pSkinu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `Skin`='%d' WHERE `username`='%e'"PlayerInfo[playerid][pSkin], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pIPu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET IP='%e' WHERE username='%e'"PlayerInfo[playerid][pIP], playerName);
                    
mysql_pquery(handlestring);
                }
                case 
pLastLoginu:
                {
                    
mysql_format(handlestringsizeof(string), "UPDATE players SET `LastLogin`= CURRENT_TIMESTAMP WHERE `username`='%e'"playerName);
                    
mysql_pquery(handlestring);
                }
            }
        }
    }
}


and 
most of them  mysql_format(handlequerysizeof(query), "INSERT INTO `players` (`username`,`password`) VALUES ('%e', MD5('%e'))"pNamepassword);
        
mysql_tquery(handlequery""""); 
So i just get warnings for every update im tryingto made...
DyduShxD is offline   Reply With Quote
Old 26/01/2019, 07:31 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: Mysql Trouble

Variable `handle` must have MySQL: tag when being declared.
Calisthenics is offline   Reply With Quote
Old 26/01/2019, 07:34 PM   #3
DyduShxD
Gangsta
 
DyduShxD's Avatar
 
Join Date: Jan 2013
Location: United Kingdom
Posts: 611
Reputation: 6
Default Re: Mysql Trouble

WHUT thank you so much buddy. Still have 2 more ..


cache_get_value_index_bool(rows, fields, handle);
cache_get_value_index_bool(rows, fields, handle);
DyduShxD is offline   Reply With Quote
Old 26/01/2019, 07:43 PM   #4
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: Mysql Trouble

pawn Code:
native cache_get_value_index_bool(row_idx, column_idx, &bool:destination);

Did you try to convert `cache_get_data` function? It does not exist anymore, so use cache_num_rows() macro or cache_get_row_count(&rows) function.
Calisthenics is offline   Reply With Quote
Old 26/01/2019, 07:47 PM   #5
DyduShxD
Gangsta
 
DyduShxD's Avatar
 
Join Date: Jan 2013
Location: United Kingdom
Posts: 611
Reputation: 6
Default Re: Mysql Trouble

Code:
function WhenPlayerLogin(playerid)
{
    if(IsPlayerConnected(playerid))
	{
	    new string[256];
	    new pName[30];
		GetPlayerName(playerid, pName, sizeof(pName));

	    cache_get_value_index(rows, fields, handle);

		if(rows != 0)
		{
		     mysql_fetch_field_row(0, "password", temp),  format(PlayerInfo[playerid][pPassword], 128, temp);
			 mysql_fetch_field_row(0, "Level", temp), PlayerInfo[playerid][pLevel] = strval(temp);
			 mysql_fetch_field_row(0, "AdminLevel", temp), PlayerInfo[playerid][pAdmin] = strval(temp);
			 mysql_fetch_field_row(0, "HelperLevel", temp), PlayerInfo[playerid][pHelper] = strval(temp);
			 mysql_fetch_field_row(0, "Cash", temp), PlayerInfo[playerid][pCash] = strval(temp);
			 mysql_fetch_field_row(0, "Account", temp), PlayerInfo[playerid][pAccount] = strval(temp);
			 mysql_fetch_field_row(0, "Email", temp),  format(PlayerInfo[playerid][pEmail], 256, temp);
			 mysql_fetch_field_row(0, "Registred", temp), PlayerInfo[playerid][pRegistred] = strval(temp);
			 mysql_fetch_field_row(0, "Tutorial", temp), PlayerInfo[playerid][pTutorial] = strval(temp);
			 mysql_fetch_field_row(0, "Sex", temp), PlayerInfo[playerid][pSex] = strval(temp);
			 mysql_fetch_field_row(0, "Age", temp), PlayerInfo[playerid][pAge] = strval(temp);
			 mysql_fetch_field_row(0, "PhoneNumber", temp), PlayerInfo[playerid][pPhoneNumber] = strval(temp);
			 mysql_fetch_field_row(0, "PremiumAccount", temp), PlayerInfo[playerid][pPremiumAccount] = strval(temp);
			 mysql_fetch_field_row(0, "Banned", temp), PlayerInfo[playerid][pBanned] = strval(temp);
			 mysql_fetch_field_row(0, "Warns", temp), PlayerInfo[playerid][pWarns] = strval(temp);
			 mysql_fetch_field_row(0, "Leader", temp), PlayerInfo[playerid][pLeader] = strval(temp);
			 mysql_fetch_field_row(0, "Member", temp), PlayerInfo[playerid][pMember] = strval(temp);
			 mysql_fetch_field_row(0, "Rank", temp), PlayerInfo[playerid][pRank] = strval(temp);
			 mysql_fetch_field_row(0, "Skin", temp), PlayerInfo[playerid][pSkin] = strval(temp);
			 mysql_fetch_field_row(0, "IP", temp), PlayerInfo[playerid][pIP] = strval(temp);
		}
		else
		{
			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit");
	        return 1;
		}

		if(PlayerInfo[playerid][pRegistred] == 0)
		{
            PlayerInfo[playerid][pLevel] = 1;
            Update(playerid, pLevelu);

            PlayerInfo[playerid][pAdmin] = 0;
            Update(playerid, pAdminu);

            GivePlayerCash(playerid, 150);

            PlayerInfo[playerid][pAccount] = 500;
            Update(playerid, pAccountu);

            PlayerInfo[playerid][pRegistred] = 1;
			Update(playerid, pRegistredu);

			new randomphonenumber = 1000000 + random(9999999);
			PlayerInfo[playerid][pPhoneNumber] = randomphonenumber;
			Update(playerid, pPhoneNumberu);

			PlayerInfo[playerid][pInterior] = 0;
  		}

        if(PlayerInfo[playerid][pBanned] == 1)
		{
		    KickWithMessage(playerid, COLOR_LIGHTRED2, "Your account is currently banned.");
		    KickWithMessage(playerid, COLOR_LIGHTRED2, "In case you think this is a confusion, request an unban at the forums.");
		}

        GetPlayerCash(playerid);

		SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  		SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);
		new rand = random(sizeof(SpawnCivR));
		SetSpawnInfo(playerid, 0, 0, SpawnCivR[rand][0],SpawnCivR[rand][1],SpawnCivR[rand][2],SpawnCivR[rand][3], 0, 0, 0, 0, 0, 0);
		SpawnPlayer(playerid);

		Update(playerid, pLastLoginu);

		new pNameIP[256];
		GetPlayerIp(playerid, pNameIP, sizeof(pNameIP));

		strmid(PlayerInfo[playerid][pIP], pNameIP, 0, 100, 255);
		Update(playerid, pIPu);


		if (PlayerInfo[playerid][pAdmin] >= 1)
		{
			format(string, sizeof(string), "You're logged in as a level %d admin.", PlayerInfo[playerid][pAdmin]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
		}

		if (PlayerInfo[playerid][pHelper] >= 1)
		{
			format(string, sizeof(string), "You're logged in as a level %d helper.", PlayerInfo[playerid][pHelper]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
		}

		if (PlayerInfo[playerid][pPremiumAccount] >= 1)
		{
			SendClientMessage(playerid, COLOR_WHITE,"You're a premium account user. ");
		}

		printf("%s has logged in.", pName);

		gLogged[playerid] = 1;
	}

	return 1;
}
Look here is the problem.. u can see it on top... Sorry but i just want to make this start and that;s it..
DyduShxD is offline   Reply With Quote
Old 26/01/2019, 07:52 PM   #6
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: Mysql Trouble

`cache_get_data` used to pass by reference the row count. You can just do:
pawn Code:
if (cache_num_rows())
{
    // cache functions to retrieve
}
or
pawn Code:
new rows;

cache_get_row_count(rows);

if (rows)
{
    // cache functions to retrieve
}

Do not use `mysql_fetch_field_row` macro or whatever that is and then converting to integet/float using `strval` or `floatstr`. There are `cache_get_value_int` and `cache_get_value_float` functions.
Calisthenics is offline   Reply With Quote
Old 26/01/2019, 08:03 PM   #7
DyduShxD
Gangsta
 
DyduShxD's Avatar
 
Join Date: Jan 2013
Location: United Kingdom
Posts: 611
Reputation: 6
Default Re: Mysql Trouble

Still same problem. ive tried.
Code:
public WhenPlayerLogin(playerid)
{
    if(IsPlayerConnected(playerid))
	{
	    new string[256];
	    new pName[30];
		GetPlayerName(playerid, pName, sizeof(pName));

	    cache_get_data(rows, fields, handle);

		if(rows != 0)
		{
		    cache_get_field_content(0, "password", temp),  format(PlayerInfo[playerid][pPassword], 128, temp);
			cache_get_field_content(0, "Level", temp), PlayerInfo[playerid][pLevel] = strval(temp);
			cache_get_field_content(0, "AdminLevel", temp), PlayerInfo[playerid][pAdmin] = strval(temp);
			cache_get_field_content(0, "HelperLevel", temp), PlayerInfo[playerid][pHelper] = strval(temp);
			cache_get_field_content(0, "Cash", temp), PlayerInfo[playerid][pCash] = strval(temp);
			cache_get_field_content(0, "Account", temp), PlayerInfo[playerid][pAccount] = strval(temp);
			cache_get_field_content(0, "Email", temp),  format(PlayerInfo[playerid][pEmail], 256, temp);
			cache_get_field_content(0, "Registred", temp), PlayerInfo[playerid][pRegistred] = strval(temp);
			cache_get_field_content(0, "Tutorial", temp), PlayerInfo[playerid][pTutorial] = strval(temp);
			cache_get_field_content(0, "Sex", temp), PlayerInfo[playerid][pSex] = strval(temp);
			cache_get_field_content(0, "Age", temp), PlayerInfo[playerid][pAge] = strval(temp);
			cache_get_field_content(0, "PhoneNumber", temp), PlayerInfo[playerid][pPhoneNumber] = strval(temp);
			cache_get_field_content(0, "PremiumAccount", temp), PlayerInfo[playerid][pPremiumAccount] = strval(temp);
			cache_get_field_content(0, "Banned", temp), PlayerInfo[playerid][pBanned] = strval(temp);
			cache_get_field_content(0, "Warns", temp), PlayerInfo[playerid][pWarns] = strval(temp);
			cache_get_field_content(0, "Leader", temp), PlayerInfo[playerid][pLeader] = strval(temp);
			cache_get_field_content(0, "Member", temp), PlayerInfo[playerid][pMember] = strval(temp);
			cache_get_field_content(0, "Rank", temp), PlayerInfo[playerid][pRank] = strval(temp);
			cache_get_field_content(0, "Skin", temp), PlayerInfo[playerid][pSkin] = strval(temp);
			cache_get_field_content(0, "IP", temp), PlayerInfo[playerid][pIP] = strval(temp);
		}
		else
		{
			ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit");
	        return 1;
		}

		if(PlayerInfo[playerid][pRegistred] == 0)
		{
            PlayerInfo[playerid][pLevel] = 1;
            Update(playerid, pLevelu);

            PlayerInfo[playerid][pAdmin] = 0;
            Update(playerid, pAdminu);

            GivePlayerCash(playerid, 150);

            PlayerInfo[playerid][pAccount] = 500;
            Update(playerid, pAccountu);

            PlayerInfo[playerid][pRegistred] = 1;
			Update(playerid, pRegistredu);

			new randomphonenumber = 1000000 + random(9999999);
			PlayerInfo[playerid][pPhoneNumber] = randomphonenumber;
			Update(playerid, pPhoneNumberu);

			PlayerInfo[playerid][pInterior] = 0;
  		}

        if(PlayerInfo[playerid][pBanned] == 1)
		{
		    KickWithMessage(playerid, COLOR_LIGHTRED2, "Your account is currently banned.");
		    KickWithMessage(playerid, COLOR_LIGHTRED2, "In case you think this is a confusion, request an unban at the forums.");
		}

        GetPlayerCash(playerid);

		SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
  		SetPlayerCash(playerid, PlayerInfo[playerid][pCash]);

		SetSpawnInfo(playerid, 0, 0, 1742.9515, -1862.3721, 13.5764, 359.5591, 0, 0, 0, 0, 0, 0);
		SpawnPlayer(playerid);

		Update(playerid, pLastLoginu);

		new pNameIP[256];
		GetPlayerIp(playerid, pNameIP, sizeof(pNameIP));

		strmid(PlayerInfo[playerid][pIP], pNameIP, 0, 100, 255);
		Update(playerid, pIPu);


		if (PlayerInfo[playerid][pAdmin] >= 1)
		{
			format(string, sizeof(string), "You're logged in as a level %d admin.", PlayerInfo[playerid][pAdmin]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
		}

		if (PlayerInfo[playerid][pHelper] >= 1)
		{
			format(string, sizeof(string), "You're logged in as a level %d helper.", PlayerInfo[playerid][pHelper]);
			SendClientMessage(playerid, COLOR_YELLOW2, string);
		}

		if (PlayerInfo[playerid][pPremiumAccount] >= 1)
		{
			SendClientMessage(playerid, COLOR_WHITE,"You're a premium account user. ");
		}

		printf("%s has logged in.", pName);

		gLogged[playerid] = 1;
	}

	return 1;
}
Thhis is right code as it was.
DyduShxD is offline   Reply With Quote
Old 26/01/2019, 08:10 PM   #8
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 821
Reputation: 125
Default Re: Mysql Trouble

Where are these 'types' defined at?

You could of simplified it by adding the enumerator tag behind the parameter.

Code:
Update(playerid, PLAYER_INFO_ENUM:type)
Use it as:

Code:
Update(playerid, pRank);

PlayerInfo[playerid][type]
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is online now   Reply With Quote
Old 26/01/2019, 08:13 PM   #9
DyduShxD
Gangsta
 
DyduShxD's Avatar
 
Join Date: Jan 2013
Location: United Kingdom
Posts: 611
Reputation: 6
Default Re: Mysql Trouble

Problem solved thank you all for your help. seems that appear other thing now my server is run time error when i start it

Last edited by DyduShxD; 26/01/2019 at 09:33 PM.
DyduShxD is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Trouble! vlat Server Support 4 01/08/2013 04:45 PM
MySQL Trouble Rufio Scripting Help 2 13/07/2013 09:03 PM
Trouble with MySQL Rufio Server Support 6 10/02/2013 09:45 PM
Trouble, trouble, trouble... with strcmp I'm assuming 2KY Scripting Help 2 31/08/2012 04:39 AM
mysql lil' trouble fordawinzz Help Archive 0 15/08/2011 10:27 PM


All times are GMT. The time now is 12:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.