19.08.2010, 19:55
Well i've been working on my onplayerlogin and everytime someone loggs in i get a buncha syntax errors, The passwords and username work fine but i keep getting the syntax errors and i can't figure out why, Anyone mind helping?
Yes i admit i used some of City Wide role play code since this mysql shiznit is new to me and i'd like to learn it.
Syntax Errors
I have looked over it many times and i haven't been able to find anything wrong with the code, My database is in the same order as this is.
Not to sure if you need these also so i'll post them anyway.
pawn Код:
public OnPlayerLogin(playerid,password[])
{
MySQLCheckConnection();
new tmp2[512];
new string2[64];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(tmp2, sizeof(tmp2), "SELECT COUNT(*) FROM players WHERE Username='%s'", playername2);
mysql_query(tmp2);
//if (DEBUG) SQLLog(tmp2);
mysql_store_result();
mysql_fetch_row(tmp2);
new registered = strval(tmp2);
if (registered < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You have not register on the site, Please register at .");
Kick(playerid);
return 0;
}
mysql_free_result();
split(playername2, playernamesplit, '_');
if (!strlen(playernamesplit[0]) || !strlen(playernamesplit[1])) {
SendClientMessage(playerid, COLOR_LIGHTRED, "Your name is not RP. User format: Firstname_Lastname");
}
new ipaddress[16];
GetPlayerIp(playerid, ipaddress, sizeof(ipaddress));
MySQLFetchAcctSingle(PlayerInfo[playerid][pID], "Password", PlayerInfo[playerid][pKey]);
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new SQLField[1024];
new slrp = 1;
MySQLFetchAcctRecord(PlayerInfo[playerid][pID], SQLField);
mysql_fetch_row(SQLField, "|");
while (mysql_fetch_row(SQLField, "|")==1)
{
if (slrp == 3) PlayerInfo[playerid][pAge] = strval(SQLField);
if (slrp == 4) PlayerInfo[playerid][pReligon] = strval(SQLField);
if (slrp == 5) PlayerInfo[playerid][pLeftX] = floatstr(SQLField);
if (slrp == 6) PlayerInfo[playerid][pLeftY] = floatstr(SQLField);
if (slrp == 7) PlayerInfo[playerid][pLeftZ] = floatstr(SQLField);
if (slrp == 8) PlayerInfo[playerid][pLeftInt] = strval(SQLField);
if (slrp == 9) PlayerInfo[playerid][pLeftW] = strval(SQLField);
if (slrp == 10) PlayerInfo[playerid][pCash] = strval(SQLField);
if (slrp == 11) PlayerInfo[playerid][pSkin] = strval(SQLField);
if (slrp == 12) PlayerInfo[playerid][pAdmin] = strval(SQLField);
if (slrp == 13) PlayerInfo[playerid][pModerator] = strval(SQLField);
if (slrp == 14) PlayerInfo[playerid][pFaction] = strval(SQLField);
if (slrp == 15) PlayerInfo[playerid][pRank] = strval(SQLField);
if (slrp == 16) PlayerInfo[playerid][pWLevel] = strval(SQLField);
if (slrp == 17) PlayerInfo[playerid][pJailed] = strval(SQLField);
if (slrp == 18) PlayerInfo[playerid][pJailTime] = strval(SQLField);
if (slrp == 19) PlayerInfo[playerid][pHealth] = floatstr(SQLField);
if (slrp == 20) PlayerInfo[playerid][pArmour] = floatstr(SQLField);
if (slrp == 21) PlayerInfo[playerid][pHours] = strval(SQLField);
if (slrp == 22) PlayerInfo[playerid][pPaycheck] = strval(SQLField);
if (slrp == 23) PlayerInfo[playerid][pAllowedPayday] = strval(SQLField);
if (slrp == 24) PlayerInfo[playerid][pBank] = strval(SQLField);
if (slrp == 25) PlayerInfo[playerid][pLevel] = strval(SQLField);
if (slrp == 26) PlayerInfo[playerid][pCarlic] = strval(SQLField);
if (slrp == 27) PlayerInfo[playerid][pFighting] = strval(SQLField);
if (slrp == 28) PlayerInfo[playerid][pLockerM] = strval(SQLField);
if (slrp == 29) PlayerInfo[playerid][pCard] = strval(SQLField);
if (slrp == 30) PlayerInfo[playerid][pCardM] = strval(SQLField);
if (slrp == 31) PlayerInfo[playerid][p9mm] = strval(SQLField);
if (slrp == 32) PlayerInfo[playerid][pEagle] = strval(SQLField);
if (slrp == 33) PlayerInfo[playerid][pShotgun] = strval(SQLField);
if (slrp == 34) PlayerInfo[playerid][pMsmg] = strval(SQLField);
if (slrp == 35) PlayerInfo[playerid][pAK] = strval(SQLField);
if (slrp == 36) PlayerInfo[playerid][pCountry] = strval(SQLField);
if (slrp == 37) PlayerInfo[playerid][pLocked] = strval(SQLField);
if (slrp == 38) PlayerInfo[playerid][pCK] = strval(SQLField);
if (slrp == 39) PlayerInfo[playerid][pWeaplic] = strval(SQLField);
if (slrp == 40) PlayerInfo[playerid][pFishlic] = strval(SQLField);
if (slrp == 41) PlayerInfo[playerid][pFishes] = strval(SQLField);
if (slrp == 42) PlayerInfo[playerid][pWeedSeeds] = strval(SQLField);
if (slrp == 43) PlayerInfo[playerid][pWeed] = strval(SQLField);
if (slrp == 44) PlayerInfo[playerid][pCokeSeeds] = strval(SQLField);
if (slrp == 45) PlayerInfo[playerid][pCoke] = strval(SQLField);
if (slrp == 46) PlayerInfo[playerid][pShroomSeeds] = strval(SQLField);
if (slrp == 47) PlayerInfo[playerid][pShrooms] = strval(SQLField);
if (slrp == 48) PlayerInfo[playerid][pLSD] = strval(SQLField);
if (slrp == 49) PlayerInfo[playerid][pGotArmour] = strval(SQLField);
if (slrp == 50) PlayerInfo[playerid][pPhone] = strval(SQLField);
if (slrp == 51) PlayerInfo[playerid][pPhonenumber] = strval(SQLField);
if (slrp == 52) PlayerInfo[playerid][pPhoneC] = strval(SQLField);
if (slrp == 53) PlayerInfo[playerid][pContacts] = strval(SQLField);
if (slrp == 54) PlayerInfo[playerid][pBiz1] = strval(SQLField);
if (slrp == 55) PlayerInfo[playerid][pBiz2] = strval(SQLField);
if (slrp == 56) PlayerInfo[playerid][pGPS] = strval(SQLField);
if (slrp == 57) PlayerInfo[playerid][pPhoneb] = strval(SQLField);
if (slrp == 58) PlayerInfo[playerid][pLaptop] = strval(SQLField);
if (slrp == 59) PlayerInfo[playerid][pVirus] = strval(SQLField);
if (slrp == 60) PlayerInfo[playerid][pAntiVirus] = strval(SQLField);
if (slrp == 61) PlayerInfo[playerid][pPMin] = strval(SQLField);
if (slrp == 62) PlayerInfo[playerid][pSpawn] = strval(SQLField);
if (slrp == 63) PlayerInfo[playerid][pCrashed] = strval(SQLField);
if (slrp == 64) PlayerInfo[playerid][pWalk] = strval(SQLField);
if (slrp == 65) PlayerInfo[playerid][pSex] = strval(SQLField);
if (slrp == 66) PlayerInfo[playerid][pJob] = strval(SQLField);
if (slrp == 67) PlayerInfo[playerid][pOutfit1] = strval(SQLField);
if (slrp == 68) PlayerInfo[playerid][pOutfit2] = strval(SQLField);
if (slrp == 69) PlayerInfo[playerid][pOutfit3] = strval(SQLField);
if (slrp == 70) PlayerInfo[playerid][pShovel] = strval(SQLField);
if (slrp == 71) PlayerInfo[playerid][pKnife] = strval(SQLField);
if (slrp == 72) PlayerInfo[playerid][pBaseball] = strval(SQLField);
if (slrp == 73) PlayerInfo[playerid][pBomb] = strval(SQLField);
if (slrp == 74) PlayerInfo[playerid][pBombMats] = strval(SQLField);
if (slrp == 75) PlayerInfo[playerid][pAJailed] = strval(SQLField);
if (slrp == 76) PlayerInfo[playerid][pWatch] = strval(SQLField);
if (slrp == 77) PlayerInfo[playerid][pMats] = strval(SQLField);
if (slrp == 78) PlayerInfo[playerid][pM4] = strval(SQLField);
if (slrp == 79) PlayerInfo[playerid][pSniper] = strval(SQLField);
if (slrp == 80) PlayerInfo[playerid][pSawn] = strval(SQLField);
if (slrp == 81) PlayerInfo[playerid][pFlame] = strval(SQLField);
if (slrp == 82) PlayerInfo[playerid][pDead] = strval(SQLField);
if (slrp == 83) PlayerInfo[playerid][pVIP] = strval(SQLField);
if (slrp == 84) PlayerInfo[playerid][pHouse1] = strval(SQLField);
if (slrp == 85) PlayerInfo[playerid][pHouse2] = strval(SQLField);
if (slrp == 86) PlayerInfo[playerid][pRent] = strval(SQLField);
if (slrp == 87) PlayerInfo[playerid][pGun1] = strval(SQLField);
if (slrp == 88) PlayerInfo[playerid][pGun2] = strval(SQLField);
if (slrp == 89) PlayerInfo[playerid][pGun3] = strval(SQLField);
if (slrp == 90) PlayerInfo[playerid][pGun4] = strval(SQLField);
if (slrp == 91) PlayerInfo[playerid][pGun5] = strval(SQLField);
if (slrp == 92) PlayerInfo[playerid][pGun6] = strval(SQLField);
if (slrp == 93) PlayerInfo[playerid][pGun7] = strval(SQLField);
if (slrp == 94) PlayerInfo[playerid][pGun8] = strval(SQLField);
if (slrp == 96) PlayerInfo[playerid][pGun9] = strval(SQLField);
if (slrp == 97) PlayerInfo[playerid][pGun10] = strval(SQLField);
if (slrp == 98) PlayerInfo[playerid][pGun11] = strval(SQLField);
if (slrp == 99) PlayerInfo[playerid][pGun12] = strval(SQLField);
if (slrp == 100) PlayerInfo[playerid][pAmmo1] = strval(SQLField);
if (slrp == 101) PlayerInfo[playerid][pAmmo2] = strval(SQLField);
if (slrp == 102) PlayerInfo[playerid][pAmmo3] = strval(SQLField);
if (slrp == 103) PlayerInfo[playerid][pAmmo4] = strval(SQLField);
if (slrp == 104) PlayerInfo[playerid][pAmmo5] = strval(SQLField);
if (slrp == 105) PlayerInfo[playerid][pAmmo6] = strval(SQLField);
if (slrp == 106) PlayerInfo[playerid][pAmmo7] = strval(SQLField);
if (slrp == 107) PlayerInfo[playerid][pAmmo8] = strval(SQLField);
if (slrp == 108) PlayerInfo[playerid][pAmmo9] = strval(SQLField);
if (slrp == 109) PlayerInfo[playerid][pAmmo10] = strval(SQLField);
if (slrp == 110) PlayerInfo[playerid][pAmmo11] = strval(SQLField);
if (slrp == 111) PlayerInfo[playerid][pAmmo12] = strval(SQLField);
if (slrp == 112) PlayerInfo[playerid][pMask] = strval(SQLField);
if (slrp == 113) PlayerInfo[playerid][pPrison] = strval(SQLField);
if (slrp == 114) PlayerInfo[playerid][pPrisonTime] = strval(SQLField);
if (slrp == 115) PlayerInfo[playerid][pLGun1] = strval(SQLField);
if (slrp == 116) PlayerInfo[playerid][pLAmmo1] = strval(SQLField);
if (slrp == 117) PlayerInfo[playerid][pLGun2] = strval(SQLField);
if (slrp == 118) PlayerInfo[playerid][pLAmmo2] = strval(SQLField);
if (slrp == 119) PlayerInfo[playerid][pLGun3] = strval(SQLField);
if (slrp == 120) PlayerInfo[playerid][pLAmmo3] = strval(SQLField);
if (slrp == 121) PlayerInfo[playerid][pCigars] = strval(SQLField);
if (slrp == 122) PlayerInfo[playerid][pTimesSmoked] = strval(SQLField);
if (slrp == 123) PlayerInfo[playerid][pDisease] = strval(SQLField);
if (slrp == 124) PlayerInfo[playerid][pSpray] = strval(SQLField);
if (slrp == 125) PlayerInfo[playerid][pBattery] = strval(SQLField);
if (slrp == 126) PlayerInfo[playerid][pBug] = strval(SQLField);
if (slrp == 127) PlayerInfo[playerid][pInt] = strval(SQLField);
if (slrp == 128) PlayerInfo[playerid][pLocal] = strval(SQLField);
if (slrp == 129) PlayerInfo[playerid][pExp] = strval(SQLField);
if (slrp == 130) PlayerInfo[playerid][pDays] = strval(SQLField);
if (slrp == 131) PlayerInfo[playerid][pFlyLicense] = strval(SQLField);
if (slrp == 132) PlayerInfo[playerid][pPcarkey] = strval(SQLField);
if (slrp == 133) PlayerInfo[playerid][pPcarkey2] = strval(SQLField);
if (slrp == 134) PlayerInfo[playerid][pPcarkey3] = strval(SQLField);
if (slrp == 135) PlayerInfo[playerid][pIP] = strval(SQLField);
if (slrp == 136) PlayerInfo[playerid][pAccepted] = strval(SQLField);
if (slrp == 137) PlayerInfo[playerid][pWarns] = strval(SQLField);
if (slrp == 138) PlayerInfo[playerid][pBanned] = strval(SQLField);
if (slrp == 139) PlayerInfo[playerid][pContractTime] = strval(SQLField);
slrp++;
}
Syntax Errors
Код:
[08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1. [08/19/10 14:38:06] Error (0): Could not execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Mod=0,Faction=255,Rank=255,WantedLevel=0,Jailed=0,JailTime=0,Health='50.000000',' at line 1.
Not to sure if you need these also so i'll post them anyway.
pawn Код:
forward MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[]);
public MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[])
{
new query[128];
format(query, sizeof(query), "SELECT %s FROM players WHERE id = %d LIMIT 1", sqlvalname, sqlplayerid);
mysql_query(query);
//if (DEBUG) SQLLog(query);
mysql_store_result();
if(mysql_fetch_row(sqlresult)==1)
{
mysql_free_result();
return 1;
}
return 0;
}
pawn Код:
forward MySQLFetchAcctRecord(sqlplayerid, sqlresult[]);
public MySQLFetchAcctRecord(sqlplayerid, sqlresult[])
{
new query[64];
format(query, sizeof(query), "SELECT * FROM players WHERE id = %d LIMIT 1", sqlplayerid);
mysql_query(query);
//if (DEBUG) SQLLog(query);
mysql_store_result();
if(mysql_fetch_row(sqlresult)==1)
{
mysql_free_result();
return 1;
}
return 0;
}