MySQL error
#1

Errors with my MySQL, copied from a tutorial so I don't have a clue about it, I only know how to use saving/loading though Y_INI and similar things. (Converting script from Y_INI to MySQL, nearly done except for these)

(2120) : error 075: input line too long (after substitutions)
(2121) : error 037: invalid string (possibly non-terminated string)
(2121) : error 017: undefined symbol "SELECT"
(2121) : error 017: undefined symbol "cash"
(2121) : fatal error 107: too many error messages on one line

pawn Код:
stock MySQL_Login(playerid)
{
    new query[5426], pname[24], savingstring[6425];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT cash, deposit, payday, paycheck, connecttime, age, sex, level, number, phonebook, job, skin, team, accent, admin, spectate, banned, muted, reportmuted, \
    experiance, vip, vipmuted, jailed, jailtime, toggedvipchat, housekey, warns, posx, posy, posz, posa, health, armor, materials, cocaine, packages, interior, virtualworld, dice, \ //(2120) : error 075: input line too long (after substitutions)
    weapon1, weapon1a, weapon2, weapon2a, weapon3, weapon3a, weapon4, weapon4a, weapon5, weapon5a, weapon6, weapon6a, weapon7, weapon7a, weapon8, weapon8a, weapon9, weapon9a, weapon10, \ //(2121) : error 037: invalid string (possibly non-terminated string)...
    weapon10a, weapon11, weapon11a, weapon12, weapon12a, killlog0, killlog1, killlog2, killlog3, killlog4, killlog5, killlog6, killlog7, killlog8, killlog9, deaths, faction, rank, leader, \
    duty, crimes, wantedlevel, radio, radiofreq, spam, dashboard FROM playerdata WHERE user = '%s'"
, pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "cash"); PlayerInfo[playerid][pCash] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "deposit"); PlayerInfo[playerid][pDeposit] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "payday"); PlayerInfo[playerid][pPayDay] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "paycheck"); PlayerInfo[playerid][pPayCheck] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "connecttime"); PlayerInfo[playerid][pConnectTime] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "age"); PlayerInfo[playerid][pAge] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "sex"); PlayerInfo[playerid][pSex] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "level"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "number"); PlayerInfo[playerid][pNumber] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "phonebook"); PlayerInfo[playerid][pPB] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "job"); PlayerInfo[playerid][pJobID] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "skin"); PlayerInfo[playerid][pSkin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "team"); PlayerInfo[playerid][pTeam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "accent"); PlayerInfo[playerid][pAccent] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "admin"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "spectate"); PlayerInfo[playerid][pSpectate] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "banned"); PlayerInfo[playerid][pBanned] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "muted"); PlayerInfo[playerid][pMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "reportmuted"); PlayerInfo[playerid][pReportMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "experiance"); PlayerInfo[playerid][pExp] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "vip"); PlayerInfo[playerid][pVip] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "vipmuted"); PlayerInfo[playerid][pVMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailed"); PlayerInfo[playerid][pJailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailtime"); PlayerInfo[playerid][pJailTime] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "toggedvipchat"); PlayerInfo[playerid][pToggedVIPChat] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "housekey"); PlayerInfo[playerid][pHousekey] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "warns"); PlayerInfo[playerid][pWarns] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posx"); PlayerInfo[playerid][pPos_x] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posy"); PlayerInfo[playerid][pPos_y] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posz"); PlayerInfo[playerid][pPos_z] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posa"); PlayerInfo[playerid][pPos_a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "health"); PlayerInfo[playerid][pHealth] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "armor"); PlayerInfo[playerid][pArmor] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "materials"); PlayerInfo[playerid][pMaterials] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "cocaine"); PlayerInfo[playerid][pCocaine] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "packages"); PlayerInfo[playerid][pPackages] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "interior"); PlayerInfo[playerid][pINT] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "virtualworld"); PlayerInfo[playerid][pVW] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "dice"); PlayerInfo[playerid][pDice] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon1"); PlayerInfo[playerid][pWeapon1] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon1a"); PlayerInfo[playerid][pWeapon1a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon2"); PlayerInfo[playerid][pWeapon2] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon2a"); PlayerInfo[playerid][pWeapon2a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon3"); PlayerInfo[playerid][pWeapon3] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon3a"); PlayerInfo[playerid][pWeapon3a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon4"); PlayerInfo[playerid][pWeapon4] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon4a"); PlayerInfo[playerid][pWeapon4a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon5"); PlayerInfo[playerid][pWeapon5] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon5a"); PlayerInfo[playerid][pWeapon5a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon6"); PlayerInfo[playerid][pWeapon6] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon6a"); PlayerInfo[playerid][pWeapon6a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon7"); PlayerInfo[playerid][pWeapon7] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon7a"); PlayerInfo[playerid][pWeapon7a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon8"); PlayerInfo[playerid][pWeapon8] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon8a"); PlayerInfo[playerid][pWeapon8a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon9"); PlayerInfo[playerid][pWeapon9] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon9a"); PlayerInfo[playerid][pWeapon9a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon10"); PlayerInfo[playerid][pWeapon10] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon10a"); PlayerInfo[playerid][pWeapon10a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon11"); PlayerInfo[playerid][pWeapon11] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon11a"); PlayerInfo[playerid][pWeapon11a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon12"); PlayerInfo[playerid][pWeapon12] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "weapon12a"); PlayerInfo[playerid][pWeapon12a] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog0"); PlayerInfo[playerid][pKillLog0] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog1"); PlayerInfo[playerid][pKillLog1] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog2"); PlayerInfo[playerid][pKillLog2] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog3"); PlayerInfo[playerid][pKillLog3] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog4"); PlayerInfo[playerid][pKillLog4] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog5"); PlayerInfo[playerid][pKillLog5] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog6"); PlayerInfo[playerid][pKillLog6] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog7"); PlayerInfo[playerid][pKillLog7] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog8"); PlayerInfo[playerid][pKillLog8] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "killlog9"); PlayerInfo[playerid][pKillLog9] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "faction"); PlayerInfo[playerid][pFaction] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "rank"); PlayerInfo[playerid][pRank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "leader"); PlayerInfo[playerid][pLeader] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "duty"); PlayerInfo[playerid][pDuty] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "crimes"); PlayerInfo[playerid][pCrimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "wantedlevel"); PlayerInfo[playerid][pWantedLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "radio"); PlayerInfo[playerid][pRadio] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "radiofreq"); PlayerInfo[playerid][pRadioFreq] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "spam"); PlayerInfo[playerid][pSpam] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "dashboard"); PlayerInfo[playerid][pDashboard] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
    PlayerInfo[playerid][pLogins]++;
    SendMessage(playerid, "~g~Info: ~w~You have been logged-in!");
    return 1;
}
Reply
#2

query[5426]
savingstring[6425]

You don't need so much long strings!
Use www.lettercount.com to count characters in string.
Your query string is 794 characters long. Plus 20 characters for player name = 814. You don't need 5426 chars!

----

Your string is too long. You can make 2 shorter strings and merge it:

pawn Код:
format(query, sizeof(query), "SELECT cash, deposit, payday, paycheck, connecttime, age, sex, level, number, phonebook, job, skin, team, accent, admin, spectate, banned, muted, reportmuted, \
    experiance, vip, vipmuted, jailed, jailtime, toggedvipchat, housekey, warns, posx, posy, posz, posa, health, armor, materials, cocaine, packages, interior, virtualworld, dice, \
    weapon1, weapon1a, weapon2, weapon2a, weapon3, weapon3a, weapon4, weapon4a,"
);
    format(query, sizeof(query), "%s weapon5, weapon5a, weapon6, weapon6a, weapon7, weapon7a, weapon8, weapon8a, weapon9, weapon9a, weapon10, \
    weapon10a, weapon11, weapon11a, weapon12, weapon12a, killlog0, killlog1, killlog2, killlog3, killlog4, killlog5, killlog6, killlog7, killlog8, killlog9, deaths, faction, rank, leader, \
    duty, crimes, wantedlevel, radio, radiofreq, spam, dashboard FROM playerdata WHERE user = '%s'"
, query, pname);
    mysql_query(query);
Reply
#3

as pooh sad,
Dont eat his hunney but start Shortening those strings and report back
Reply
#4

Better yet, just use sscanf and then your query can look something like this:

Код:
SELECT * FROM playerdata WHERE user = '%s'
Reply
#5

No, it's not better.
Why selecting a data you actually don't need?


But yes, it's better to use sscanf to fetch the returned line.

I recommend you to use threaded queries.
Reply
#6

Aha, okay, it worked but can you help me on the saving/disconnecting part?:

(6452) : error 075: input line too long (after substitutions)
(6453) : error 037: invalid string (possibly non-terminated string)
(6453) : error 017: undefined symbol "UPDATE"
(6453) : error 017: undefined symbol "cash"
(6453) : fatal error 107: too many error messages on one line

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(Logged[playerid] == 1)
    {
        GetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
        GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPos_a]);
        new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        new query[814], pname[24];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "UPDATE cash=%d, deposit=%d, payday=%d, paycheck=%d, connecttime=%d, age=%d, sex=%d, level=%d, number=%d, phonebook=%d, job=%d, skin=%d, team=%d, accent=%d, admin=%d, spectate=%d, banned=%d, muted=%d, reportmuted=%d, \
        experiance=%d, vip=%d, vipmuted=%d, jailed=%d, jailtime=%d, toggedvipchat=%d, housekey=%d, warns=%d, posx=%f, posy=%f, posz=%f, posa=%f, health=%f, armor=%f, materials=%d, cocaine=%d, packages=%d, interior=%d, virtualworld=%d, dice=%d, \ // (6452) : error 075: input line too long (after substitutions)
        weapon1=%d, weapon1a=%d, weapon2=%d, weapon2a=%d, weapon3=%d, weapon3a=%d, weapon4=%d, weapon4a=%d,"
); //(6453) : error 037: invalid string (possibly non-terminated string)
        format(query, sizeof(query), "%s weapon5=%d, weapon5a=%d, weapon6=%d, weapon6a=%d, weapon7=%d, weapon7a=%d, weapon8=%d, weapon8a=%d, weapon9=%d, weapon9a=%d, weapon10=%d, \
        weapon10a=%d, weapon11=%d, weapon11a=%d, weapon12=%d, weapon12a=%d, killlog0=%d, killlog1=%d, killlog2=%d, killlog3=%d, killlog4=%d, killlog5=%d, killlog6=%d, killlog7=%d, killlog8=%d, killlog9=%d, deaths=%d, faction=%d, rank=%d, leader=%d, \
        duty=%d, crimes=%d, wantedlevel=%d, radio=%d, radiofreq=%d, spam=%d, dashboard=%d WHERE user = '%s'"
,
        PlayerInfo[playerid][pCash],
        PlayerInfo[playerid][pDeposit],...
Reply
#7

Make more (3) short strings.
Reply
#8

EDIT:

When opening the server I get these:

0:37:29] [debug] Run time error 19: "File or function is not found"
[00:37:29] [debug] The following natives are not registered:
[00:37:29] [debug] mysql_fetch_row_format
[00:37:29] [debug] mysql_fetch_field_row
[00:37:29] [debug] mysql_debug
[00:37:29] Script[gamemodes/LGRP.amx]: Run time error 19: "File or function is not found"
[00:37:29] Number of vehicle models: 0
Reply
#9

Use strcat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)