Login & Register schreibt nichts in die Datenbank!

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
  • Guten Tag,
    wie oben mein problem schon geschildert wurde, wird beim Registrieren nichts in die Datenbank geschrieben.


    new query[256], pass[50];
    if(dialogid == DIALOG_REGISTER)
    {
    if(!response) return Kick(playerid);
    if(strlen(inputtext) < 4) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registrierung", "Sie haben noch keinen Account, bitte erstellen sie sich eins!", "Register", "Abbrechen");
    format(pass, sizeof(pass), "%s", inputtext);
    mysql_escape_string(UserName(playerid), UserName(playerid));
    mysql_escape_string(pass, pass);
    format(query, sizeof(query), "INSERT INTO (Username, Password) VALUES ('%s', MD5('%s'))", UserName(playerid), pass);
    mysql_tquery(handle, query);
    }

  • [21:26:49] [DEBUG] mysql_errno - connection: 1
    [21:26:49] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [21:26:49] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [21:26:49] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [21:26:49] [DEBUG] CMySQLConnection::Connect - connection was successful
    [21:26:49] [DEBUG] CMySQLConnection::Connect - connection was successful
    [21:26:49] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [21:26:49] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [21:27:11] [DEBUG] mysql_escape_string - source: "Grapefruit", connection: 1, max_len: 24
    [21:27:11] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM user WHERE Username=''", callback: "CheckUser", format: "i"
    [21:27:11] [DEBUG] CMySQLQuery::Execute[CheckUser] - starting query execution
    [21:27:11] [DEBUG] CMySQLQuery::Execute[CheckUser] - query was successfully executed within 0.283 milliseconds
    [21:27:11] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [21:27:11] [DEBUG] Calling callback "CheckUser"..
    [21:27:11] [DEBUG] cache_get_data - connection: 1
    [21:27:11] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [21:27:25] [DEBUG] mysql_escape_string - source: "Grapefruit", connection: 1, max_len: 24
    [21:27:25] [DEBUG] mysql_escape_string - source: "12345", connection: 1, max_len: 50
    [21:27:25] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO user (Username, Password) VALUES ('Grapefruit', '123", callback: "(null)", format: "(null)"
    [21:27:25] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [21:27:25] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 34.330 milliseconds
    [21:27:25] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving

  • Mein Fehler hatte die falsche Datenbank aufgerufen. Beim registrieren wird der Spieler gespeichert, aber es wird nicht erkannt ob er schon ein Account hat.


    new num_rows, num_fields;
    cache_get_data(num_rows, num_fields, handle);
    if(num_rows == 0)
    {
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registrierung", "Sie haben noch keinen Account, bitte erstellen sie sich eins!", "Register", "Abbrechen");
    }
    else
    {
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Ihr Account wurde erfolgreich in der Datenbank gefunden! Bitte logge Sie sich in ihr Account ein!", "Login", "Abbrechen");
    }

  • new query[100];
    mysql_escape_string(UserName(playerid), UserName(playerid));
    format(query, sizeof(query), "SELECT * FROM user WHERE Username='%s'", PlayerInfo[playerid][pUsername]);
    mysql_pquery(handle, query, "CheckUser", "i", playerid);

  • Dann schreibe es so:
    new query[100], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    mysql_escape_string(name, name);
    format(PlayerInfo[playerid][pUsername], MAX_PLAYER_NAME, name);
    format(query, sizeof(query), "SELECT * FROM user WHERE Username='%s'", PlayerInfo[playerid][pUsername]);
    mysql_pquery(handle, query, "CheckUser", "i", playerid);

  • [22:08:00] [DEBUG] mysql_escape_string - source: "Grapefruit", connection: 1, max_len: 24
    [22:08:00] [DEBUG] mysql_escape_string - source: "12345", connection: 1, max_len: 50
    [22:08:00] [DEBUG] mysql_pquery - connection: 1, query: "INSERT INTO user (Username, Password) VALUES ('Grapefruit', MD5(", callback: "(null)", format: "(null)"
    [22:08:00] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [22:08:00] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 28.303 milliseconds
    [22:08:00] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
    [22:08:25] [DEBUG] mysql_escape_string - source: "Grapefruit", connection: 1, max_len: 24
    [22:08:25] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM user WHERE Username='Grapefruit'", callback: "CheckUser", format: "i"
    [22:08:25] [DEBUG] CMySQLQuery::Execute[CheckUser] - starting query execution
    [22:08:25] [DEBUG] CMySQLQuery::Execute[CheckUser] - query was successfully executed within 0.450 milliseconds
    [22:08:25] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [22:08:25] [DEBUG] Calling callback "CheckUser"..
    [22:08:25] [DEBUG] cache_get_data - connection: 1
    [22:08:25] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [22:08:28] [DEBUG] mysql_escape_string - source: "Grapefruit", connection: 1, max_len: 24
    [22:08:28] [DEBUG] mysql_escape_string - source: "12345", connection: 1, max_len: 50
    [22:08:28] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM user WHERE Username='Grapefruit' AND Password = MD", callback: "OnPasswordResponse", format: "i"
    [22:08:28] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - starting query execution
    [22:08:28] [DEBUG] CMySQLQuery::Execute[OnPasswordResponse] - query was successfully executed within 0.350 milliseconds
    [22:08:28] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [22:08:28] [DEBUG] Calling callback "OnPasswordResponse"..
    [22:08:28] [DEBUG] cache_get_data - connection: 1
    [22:08:28] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called


    [22:08:28] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM user WHERE Username='Grapefruit' AND Password = MD", callback: "OnPasswordResponse", format: "i"