MySQL Register

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
  • Warum wird der Spieler nicht Registreiert bzw nicht gespeichert ????




    if(dialogid == DIALOG_REGISTER)
    {
    if(strlen(inputtext) == 0)
    {
    new string[258];
    format(string,sizeof(string),"Wilkommen %s \n Dein Account wurde leider nicht gefunden. \n Bitte gebe dein Passwort ein.",SpielerName(playerid));
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register",string,"Register","Exit");
    SendClientMessage(playerid,ROT,"Bitte wähle ein anderes Passwort.");
    return 1;
    }
    else
    {
    CreateAccount(playerid, inputtext);
    SpielerInfo[playerid][pLogIn] = 1;
    SavePlayer(playerid);
    CancelSelectTextDraw(playerid);
    SpawnPlayer(playerid);
    return 1;
    }
    }



    stock CreateAccount(playerid, pass[])
    {
    new query1[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    format(query1,sizeof(query1), "INSERT INTO `accounts` (`Name`, `Passwort`) VALUES ('%s', '%s')", Name, pass);
    mysql_query(Handle,query1);
    return true;
    }

  • Was steht im MySQL Log, wenn du dich registrierst?





    [19:18:14] [DEBUG] mysql_connect - host: "127.0.0.1", user: "samp", database: "fcrp", password: "****", port: 3306, autoreconnect: true, pool_size: 2
    [19:18:14] [DEBUG] CMySQLHandle::Create - creating new connection..
    [19:18:14] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
    [19:18:14] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
    [19:18:14] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [19:18:14] [DEBUG] CMySQLConnection::Connect - connection was successful
    [19:18:14] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [19:18:14] [DEBUG] mysql_errno - connection: 1
    [19:18:14] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [19:18:14] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [19:18:14] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
    [19:18:14] [DEBUG] CMySQLConnection::Connect - connection was successful
    [19:18:14] [DEBUG] CMySQLConnection::Connect - connection was successful
    [19:18:14] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [19:18:14] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [19:18:14] [DEBUG] CMySQLConnection::Connect - connection was successful
    [19:18:14] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
    [19:18:54] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
    [19:18:54] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Name` = 'test12345' LIMIT 1", callback: "OnAccountCheck", format: "i"
    [19:18:54] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
    [19:18:54] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Name` = 'test12345' LIMIT 1", callback: "OnAccountCheck", format: "i"
    [19:18:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
    [19:18:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.368 milliseconds
    [19:18:54] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [19:18:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
    [19:18:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.72 milliseconds
    [19:18:54] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [19:18:54] [DEBUG] Calling callback "OnAccountCheck"..
    [19:18:54] [DEBUG] cache_get_row_count - connection: 1
    [19:18:54] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [19:18:54] [DEBUG] Calling callback "OnAccountCheck"..
    [19:18:54] [DEBUG] cache_get_row_count - connection: 1
    [19:18:54] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [19:18:57] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `accounts` (`Name`, `Passwort`) VALUES ('test12345',", use_cache: true
    [19:18:57] [DEBUG] CMySQLQuery::Execute - starting query execution
    [19:18:57] [ERROR] CMySQLQuery::Execute - (error #1062) Duplicate entry '0' for key 'PRIMARY'
    [19:18:57] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `Level` = '0',`Points` = '0',`Zeit` = '0',", callback: "(null)", format: "(null)"
    [19:18:57] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [19:18:57] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.243 milliseconds
    [19:18:57] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
    [19:19:38] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `Level` = '0',`Points` = '0',`Zeit` = '-5'", callback: "(null)", format: "(null)"
    [19:19:38] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [19:19:38] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.329 milliseconds
    [19:19:38] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
    [19:19:59] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `Level` = '0',`Points` = '0',`Zeit` = '-26", callback: "(null)", format: "(null)"
    [19:19:59] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [19:19:59] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.318 milliseconds
    [19:19:59] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
    [19:20:28] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
    [19:20:28] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Name` = 'test12345' LIMIT 1", callback: "OnAccountCheck", format: "i"
    [19:20:28] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1"
    [19:20:28] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Name` = 'test12345' LIMIT 1", callback: "OnAccountCheck", format: "i"
    [19:20:28] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
    [19:20:28] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.138 milliseconds
    [19:20:28] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [19:20:28] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
    [19:20:28] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.66 milliseconds
    [19:20:28] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
    [19:20:28] [DEBUG] Calling callback "OnAccountCheck"..
    [19:20:28] [DEBUG] cache_get_row_count - connection: 1
    [19:20:28] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [19:20:28] [DEBUG] Calling callback "OnAccountCheck"..
    [19:20:28] [DEBUG] cache_get_row_count - connection: 1
    [19:20:28] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
    [19:20:37] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `accounts` (`Name`, `Passwort`) VALUES ('test12345',", use_cache: true
    [19:20:37] [DEBUG] CMySQLQuery::Execute - starting query execution
    [19:20:37] [ERROR] CMySQLQuery::Execute - (error #1062) Duplicate entry '0' for key 'PRIMARY'
    [19:20:37] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `Level` = '0',`Points` = '0',`Zeit` = '-45", callback: "(null)", format: "(null)"
    [19:20:37] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [19:20:37] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.232 milliseconds
    [19:20:37] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
    [19:20:47] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET `Level` = '0',`Points` = '0',`Zeit` = '-64", callback: "(null)", format: "(null)"
    [19:20:47] [DEBUG] CMySQLQuery::Execute[] - starting query execution
    [19:20:47] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.304 milliseconds
    [19:20:47] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving



  • Lösche die Daten, die bereits in der Tabelle sind. Erst dann geht es.


    Hey nun habe Ich das Problem das nicht mehr erkannt wird ob er User bereits registriert ist.


    Und die Abfrage kommt :



    if(clickedid == Login[TextLog])
    {
    new query1[128];
    mysql_format(Handle, query1, sizeof(query1),"SELECT `Name` FROM `accounts` WHERE `Name` = '%e' LIMIT 1",SpielerName(playerid));
    mysql_pquery(Handle, query1, "OnAccountCheck", "i", playerid);
    }
    if(clickedid == Login[TextReg])
    {
    new query1[128];
    mysql_format(Handle, query1, sizeof(query1),"SELECT `Name` FROM `accounts` WHERE `Name` = '%e' LIMIT 1",SpielerName(playerid));
    mysql_pquery(Handle, query1, "OnAccountCheck", "i", playerid);
    }



    stock mysql_CheckAccount(playerid)
    {
    new query1[128],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_format(Handle, query1, sizeof(query1),"SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1",Name[playerid]);
    mysql_tquery(Handle, query1, "OnAccountCheck", "i", playerid);
    return 1;
    }


    Obwohl der Account schon registrieert ist der Name wird eine neuer angemeldet.



  • public OnAccountCheck(playerid)
    {
    new string[256];
    if(cache_get_row_count() == 0)
    {
    format(string,sizeof(string),"Wilkommen %s \n Dein Account wurde leider nicht gefunden. \n Bitte gebe dein Passwort ein.",SpielerName(playerid));
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register",string,"Register","Exit");
    }
    else
    {
    format(string,sizeof(string),"Willkommen %s \nDein Account wurde gefunden. \nBitte gebe dein Passwort ein.",SpielerName(playerid));
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"LogIn",string,"LogIn","Exit");
    }
    return 1;
    }

  • public OnAccountCheck(playerid)
    {
    new string[256], rows, fields;
    cache_get_data(rows, fields);
    if(!rows)
    {
    format(string,sizeof(string),"Wilkommen %s \n Dein Account wurde leider nicht gefunden. \n Bitte gebe dein Passwort ein.",SpielerName(playerid));
    ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register",string,"Register","Exit");
    }
    else
    {
    format(string,sizeof(string),"Willkommen %s \nDein Account wurde gefunden. \nBitte gebe dein Passwort ein.",SpielerName(playerid));
    ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"LogIn",string,"LogIn","Exit");
    }
    return 1;
    }


    Schau mal bitte, ob es so geht.

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen