Mysql error
#1

hey guys i wanted to do something from 0 and i took a gamemode from internet that has some few startup things like register/login and some few cmds i have a problem i try to edit the playerinfo and did it like this, version of mysql is R39-5

Код HTML:
forward Update(playerid, type);
enum pInfo
{
	pSQLID, pPassword[16], pRecover[32], pLogged, pLevel, pSex, pAge, pSpawn, pSkin, pMinutes, pHours, pRespect, pMoney, pBank, pLanguage,
	pAdmin, pHelper, pReports, pNewbies, pWarn, pMute, pMuteTime, pBanned, pBannedReason[125], pBanDays, pBannedBy[125], Float: pMarkX,
	Float: pMarkY, Float: pMarkZ, pCrashed, pDrivingLicenseA, pDrivingLicenseB, pDrivingLicenseC, pWeaponLicense, pFlyingLicense, pWork,
	pNavigationLicense, pAdminJailed, pAdminJailedReason[256], pAdminJailedMinutes, pAdminJailedAdmin[256], pAlreadyVoted, pTester,
}
new PlayerInfo[MAX_PLAYERS][pInfo],
	handle,
	gQuery[512];

public Update(playerid, type)
{
	if(IsPlayerConnected(playerid))
	{
		gQuery[0] = (EOS);
		{
			switch(type)
			{
			    case pRecoverx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Recover` = %d WHERE `ID` = %d", PlayerInfo[playerid][pRecover], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pLevelx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Level` = %d WHERE `ID` = %d", PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pSexx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Sex` = %d WHERE `ID` = %d", PlayerInfo[playerid][pSex], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pAgex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Age` = %d WHERE `ID` = %d", PlayerInfo[playerid][pAge], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pSpawnx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Spawn` = %d WHERE `ID` = %d", PlayerInfo[playerid][pSpawn], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pSkinx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Skin` = %d WHERE `ID` = %d", PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pMinutesx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Minutes` = %d WHERE `ID` = %d", PlayerInfo[playerid][pMinutes], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pHoursx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Hours` = %d WHERE `ID` = %d", PlayerInfo[playerid][pHours], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
			    case pRespectx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Respect` = %d WHERE `ID` = %d", PlayerInfo[playerid][pRespect], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pMoneyx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Money` = %d WHERE `ID` = %d", PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pBankx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Bank` = %d WHERE `ID` = %d", PlayerInfo[playerid][pBank], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pLanguagex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Language` = %d WHERE `ID` = %d", PlayerInfo[playerid][pLanguage], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pAdminx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Admin` = %d WHERE `ID` = %d", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pHelperx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Helper` = %d WHERE `ID` = %d", PlayerInfo[playerid][pHelper], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pReportsx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Reports` = %d WHERE `ID` = %d", PlayerInfo[playerid][pReports], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pNewbiesx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Newbies` = %d WHERE `ID` = %d", PlayerInfo[playerid][pNewbies], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pWarnx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Warn` = %d WHERE `ID` = %d", PlayerInfo[playerid][pWarn], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pMutex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Mute` = %d WHERE `ID` = %d", PlayerInfo[playerid][pMute], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pMuteTimex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `MuteTime` = %d WHERE `ID` = %d", PlayerInfo[playerid][pMuteTime], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pCrashedx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Crashed` = %d WHERE `ID` = %d", PlayerInfo[playerid][pCrashed], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pDrivingLicenseAx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `DrivingLicenseA` = %d WHERE `ID` = %d", PlayerInfo[playerid][pDrivingLicenseA], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pDrivingLicenseBx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `DrivingLicenseB` = %d WHERE `ID` = %d", PlayerInfo[playerid][pDrivingLicenseB], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pDrivingLicenseCx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `DrivingLicenseC` = %d WHERE `ID` = %d", PlayerInfo[playerid][pDrivingLicenseC], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pWeaponLicensex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `WeaponLicense` = %d WHERE `ID` = %d", PlayerInfo[playerid][pWeaponLicense], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pFlyingLicensex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `FlyingLicense` = %d WHERE `ID` = %d", PlayerInfo[playerid][pFlyingLicense], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pNavigationLicensex:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `NavigationLicense` = %d WHERE `ID` = %d", PlayerInfo[playerid][pNavigationLicense], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pAdminJailedx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `AdminJailed` = %d WHERE `ID` = %d", PlayerInfo[playerid][pAdminJailed], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pWorkx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Work` = %d WHERE `ID` = %d", PlayerInfo[playerid][pWork], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
			    case pAlreadyVotedx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `AlreadyVoted` = %d WHERE `ID` = %d", PlayerInfo[playerid][pAlreadyVoted], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
				case pTesterx:
			    {
					mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `Accounts` SET `Tester` = %d WHERE `ID` = %d", PlayerInfo[playerid][pTester], PlayerInfo[playerid][pSQLID]);
					mysql_tquery(handle, gQuery, "", "");
				}
			}
		}
	}
	return 1;
}
but when an account is created or i try to save something to an account i get this

Код HTML:
[ERROR] mysql_format - invalid connection handle (id: 0)
[ERROR] mysql_tquery - invalid connection handle (id: 0)
Reply
#2

There isn't even a connection being made ...

And also it looks like passwords are not being hashed.
Reply
#3

Код HTML:
#define         SQL_HOST	"localhost"
#define         SQL_USER    "root"
#define         SQL_PASS    ""
#define         SQL_DB      "server2"

function ConnectionDB()
{
    mysql = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
	if(mysql_errno(mysql) == 0)
	{
	    printf("SQL: The connection to database has been established successfully.", SQL_DB);
	    printf("\n");
	}
	else
	{
   		printf("SQL: %s can't connect to %s hosted on %s.", SQL_USER, SQL_DB, SQL_HOST);
  		SendRconCommand("exit");
	}
	return 1;
}

And this is under OnGameModeInit

ConnectionDB();
what is wrong ? or what i forgot ? cause the last version of saving the account worked fine but the account info's was saving every single sec and that is not good
Reply
#4

You need to use mysql instead of handle , cuz handle its not that one connect to mysql server
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)