[Problem] MySQL (Nur im Login)

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Leute... ich bin habe heute mein Account System geschrieben und ich habe ein Problem, das eigentlich nicht sein
    sollte, welches ich auch nicht kenne bzw. die Fehlerquelle erkennen kann..


    Code
    [ERROR] CMySQLQuery::Execute[OnPlayerLoad] - (error #1064) 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 ''DevLopAPI' at line 1


    DevLopAPI hier der Name der in der DB gespeichert und auch abgefragt wird



    case DIALOG_LOGIN:
    {
    if(!response)return Kick(playerid);
    new password[50];
    mysql_escape_string(inputtext, password, dbhandle);
    new query[500];
    mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s' AND `Passwort`='%s'", GetName(playerid), password);
    mysql_pquery(dbhandle, query, "OnPasswordCheck", "i", playerid);
    return 1;
    }


    public OnPasswordCheck(playerid)
    {
    new num_rows, num_fields;
    cache_get_data(num_rows, num_fields, dbhandle);
    if(num_rows)
    {
    LoadPlayer(playerid);
    LoadPoke(playerid);
    }
    else
    {
    SendClientMessage(playerid, 0xFF0000FF, "Server: Passwort falsch!");
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Bitte geben sie ihr Passwort ein,\ndamit wir wissen wie weit sie in ihrem Abenteuer vorangeschritten sind:", "Login", "");
    }
    return 1;
    }



    LoadPlayer(playerid)
    {
    new query[280];
    mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s", GetName(playerid));
    mysql_pquery(dbhandle, query, "OnPlayerLoad", "i", playerid);
    return 1;
    }


    LoadPoke(playerid)
    {
    new query[280];
    mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `pokes` WHERE `trainer`='%s'", GetName(playerid));
    mysql_pquery(dbhandle, query, "OnPokeLoad", "i", playerid);
    return 1;
    }


    public OnPlayerLoad(playerid)
    {
    pDaten[playerid][pokedollar] = cache_get_field_content_int(0, "PokeDollar", dbhandle);
    pDaten[playerid][orden] = cache_get_field_content_int(0, "Orden", dbhandle);
    pDaten[playerid][p_x] = cache_get_field_content_int(0, "X", dbhandle);
    pDaten[playerid][p_y] = cache_get_field_content_float(0, "Y", dbhandle);
    pDaten[playerid][p_z] = cache_get_field_content_float(0, "Z", dbhandle);
    pDaten[playerid][p_r] = cache_get_field_content_float(0, "R", dbhandle);
    SetPVarInt(playerid, "Eingeloggt", 1);
    SpawnPlayer(playerid);
    return 1;
    }


    public OnPokeLoad(playerid)
    {
    new num_rows, num_fields;
    cache_get_data(num_rows, num_fields, dbhandle);
    for(new i = 0; i < num_rows; i++)
    {
    cache_get_field_content(i, "Nick", Pokemon[i][playerid][Nickname], dbhandle);
    Pokemon[i][playerid][Poke] = cache_get_field_content_int(i, "Pokemon", dbhandle);
    Pokemon[i][playerid][lvl] = cache_get_field_content_int(i, "Level", dbhandle);
    Pokemon[i][playerid][item] = cache_get_field_content_int(i, "Item", dbhandle);
    Pokemon[i][playerid][xp] = cache_get_field_content_int(i, "XP", dbhandle);
    Pokemon[i][playerid][health] = cache_get_field_content_int(i, "Health", dbhandle);
    Pokemon[i][playerid][maxhealth] = cache_get_field_content_int(i, "MaxHealth", dbhandle);
    Pokemon[i][playerid][ap1] = cache_get_field_content_int(i, "AP1", dbhandle);
    Pokemon[i][playerid][ap2] = cache_get_field_content_int(i, "AP2", dbhandle);
    Pokemon[i][playerid][ap3] = cache_get_field_content_int(i, "AP3", dbhandle);
    Pokemon[i][playerid][ap4] = cache_get_field_content_int(i, "AP4", dbhandle);
    }
    new pokename[100];
    format(pokename, sizeof(pokename), "Poke(%s)", GetName(playerid));
    ConnectRNPC(pokename);
    return 1;
    }

  • mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s", GetName(playerid));
    zu:
    mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s'", GetName(playerid));


    Übrigens kannst du in mysql_format auch %e anstatt %s nutzen, dann sparst du dir die escape Funktion.

  • mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s", GetName(playerid));
    zu:
    mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `users` WHERE `name`='%s'", GetName(playerid));


    wo ist da jetzt der Unterschied?


    //Achso.... hab das ein " ' " vergessen xD



    Danke jeffry