Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 40

Thread: Probelm with MySQL register.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Create a UNIQUE key constraint in your mysql db. Then use a stored procedure (function) to create new accounts, which use a INSERT IGNORE. Then double-check on last_insert_id inside that function. Return something if successful (possibly the user's ID), and an error code if unsuccessful (-1 should do a decent job at being an error code)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  2. The Following User Says Thank You to IzNoGoD For This Useful Post:

    nightbot (23rd July 2016)

  3. #2
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Ur comment ain't helping here ..

  4. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  5. #3
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Killtube's being taken over by nuubz...

    I had to say it xD

  6. The Following User Says Thank You to YuriJurek For This Useful Post:

    kubislav23 (23rd July 2016)

  7. #4
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    none will help then :/

  8. The Following User Says Thank You to nightbot For This Useful Post:

    kubislav23 (23rd July 2016)

  9. #5
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    @IzNoGod i managed to make the login unique and primary. But i got some problems showing errors.
    If there is an account, it returns a self thread tellmessage("account exist");
    but if there is no account, it doesn't process the query.
    I think it's from my register case.
    PHP Code:
    case "register":
                       if(
    args[2].size >= && args[2].size <= 20)
                       {
                
    haslogin searchforlogin(args[2]);
                if(
    haslogin == true)
                {
                           if(
    args[3].size >= && args[3].size <= 25)
                           {
                    return;
                }
                if(
    haslogin == false)
                {
                
    iprintlnbold("ye");            
                    
    createadmin(args[2], args[3]);
                return;
                }
                }
                    
    self thread tellmessage("Password is too short or too long. Min 5 characters, max 25.");
                               return;
                       }
                    
    self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
                       return; 

  10. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Fix your indentation.

    You'll see this:
    PHP Code:
        case "register":
            if(
    args[2].size >= && args[2].size <= 20)
            {
                
    haslogin searchforlogin(args[2]);
                if(
    haslogin == true)
                {
                    if(
    args[3].size >= && args[3].size <= 25)
                    {
                        return;
                    }
                    if(
    haslogin == false)
                    {
                        
    iprintlnbold("ye");            
                        
    createadmin(args[2], args[3]);
                        return;
                    }
                }
                
    self thread tellmessage("Password is too short or too long. Min 5 characters, max 25.");
                return;
            }
            
    self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
            return; 
    the if(haslogin == false) is inside the if(haslogin == true)
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  11. #7
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    WTF? Izno..
    PHP Code:
    if(param==true)
    {
    /*...*/
    if(param==false)
    {
    /*...*/
    }
    /*...*/

    Try:
    PHP Code:
    case "register":
    {        
        if(
    args[2].size >= && args[2].size <= 20)
        {
            if(
    args[3].size >= && args[3].size <= 25)
            {
                
    haslogin searchforlogin(args[2]);
                  if(
    haslogin)
                     
    self iprintlnbold("Login taked!");    
                  else
                     if(!
    haslogin)
                     {
                     
    self iprintlnbold("Login no register!");            
                     
    createadmin(args[2], args[3]);
                     }
            }
            else
            
    self thread tellmessage("Password is too short or too long. Min 5 characters, max 25.");
        }
        else
        
    self thread tellMessage("Login is too short or too long. Min 3 characters, max 20.");
    return;

    Last edited by maxdamage99; 24th July 2016 at 09:21.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  12. The Following User Says Thank You to maxdamage99 For This Useful Post:

    nightbot (24th July 2016)

  13. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by maxdamage99 View Post
    WTF? Izno..
    I replied with HIS code properly indented to show that it is wrong.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  14. #9
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    Thx for ur help.
    Even when the user is available i get that Login taked !

    This is my searchforlogin thread
    PHP Code:
    SearchForLogin(login)
    {
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT login FROM admins WHERE login = '" maps\mp\gametypes\_mysql::stripString(login) + "' LIMIT 1", ::checkLogin);
    }

    checkLogin(rowsargs)
    {    
       if(
    isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["login"]) && isDefined(self))
       {

            
    self tellMessage("I'm sorry, but login " rows[0]["login"] + "^7 already exist. Choose another one.");
            return;
       }


    This is my query for creating the account:

    PHP Code:
    CreateAdmin(loginpass)
    {
        
    maps\mp\gametypes\_mysql::asyncQuery("INSERT INTO admins (login, pass) VALUES ('" maps\mp\gametypes\_mysql::stripString(login) + "', '" maps\mp\gametypes\_mysql::stripString(pass) + "')");
        
    self thread tellmessage("success");

    Maybe a problem in searchforlogin ?

  15. #10
    Private
    Join Date
    Jul 2016
    Posts
    21
    Thanks
    6
    Thanked 9 Times in 9 Posts
    IzNoGod it would be cool if you fix it :s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •