Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Register mysql problem

  1. #1
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts

    Register mysql problem

    Hello,
    I'm trying to make a register system using mysql. I got some problems while creating the account and saving it to mysql.
    Here's my code:
    PHP Code:
    registeraccount(usernamepassword)
    {
        
    args = [];
        
    args[0] = "register";
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT createNewAccount('" maps\mp\gametypes\_mysql::stripstring(username) + "', '" maps\mp\gametypes\_mysql::stripstring(password) + "') AS `userid`", ::recieveloginargs);

    PHP Code:
    recievelogin(rowsargs)
    {
        if(
    rows.size && isdefined(rows[0]) && isdefined(rows[0]["userid"]) && int(rows[0]["userid"]) != 0)
        {
            
    self.pers["userid"] = int(rows[0]["userid"]);
        if(
    isdefined(rows[0]["rank"]))
        {
            
    self.pers["admin"] = int(rows[0]["rank"]); 
            
    self thread tellmessage(sprintf(self.pers["admname"] + " Account opened ! Rank : ^1(^7%^1)"self.pers["admin"]));
            return;
        }
        else
        {
            
    self.pers["admin"] = 0;
            
    self.pers["admname"] = "";
            return;

        }
        if(
    args[0] == "register")
                
    self thread tellmessage("Account created !");
            
    self thread tellmessage("In case you forgot them, you will find a screehshot Info.jpeg on UdSSR mod folder");
            
    self execclientcommand("screenshotJpeg Info");
            return;
        }
        else
        {
            if(
    args[0] == "login")
                
    self thread tellmessage("Wrong Password. Which means username is taken !");
        else
            
    self thread tellmessage("Username already exists");
        }
        

    PHP Code:
    case "register":
            if(
    args[2].size >= && args[2].size <= 20
                { 
                    if(
    args[3].size >= && args[3].size <= 25)
            {
            
    registeraccount(args[2], args[3]);
            return;
              }
            
    self thread tellmessage("pw too short/long");
            return;
        }
        
    self thread tellmessage("user too short/long"); 
    When i try to !register user pass i get this in console:
    PHP Code:
    querySELECT createNewAccount('user''pass') AS `userid
    But nothing is saved to the database.

    I think my createNewAccount table settings are wrong.

    Click image for larger version. 

Name:	create.PNG 
Views:	52 
Size:	25.1 KB 
ID:	1311

    Any solutions please?
    Thanks

  2. The Following 2 Users Say Thank You to suck000 For This Useful Post:

    kubislav23 (16th April 2017),kung foo man (16th April 2017)

  3. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Your SQL query is wrong. You need a 'INSERT' query.

    See the site below for the SQL basics:
    https://www.w3schools.com/sql/sql_insert.asp

    Full MySQL documentation:
    https://dev.mysql.com/doc/refman/5.7/en/insert.html

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

    kung foo man (16th April 2017)

  5. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    I see you're using a mysql function. Where is the code for it?

    I see you're using a mysql function. Did you allow the user to execute it?

    I see you're trying to get multiple columns returned from a mysql function. This is not possible.

    I see your code is not properly indented, making some if()'s do different things than you think they do.

    I see you're using sprintf plus cod2 string concat. This is weird.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

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

    kung foo man (16th April 2017)

  7. #4
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    tv later? izno? i already friend @skype w/ u

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

    kubislav23 (16th April 2017)

  9. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    No, go read a mysql 101 guide.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  10. #6
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Dude you wrote to me the query past july by tv. You just told me to do not touch anything and you did the job. I just need the query.

  11. The Following User Says Thank You to suck000 For This Useful Post:

    kubislav23 (16th April 2017)

  12. #7
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    I can pay you just help me i really need the server ready so soon.

  13. The Following User Says Thank You to suck000 For This Useful Post:

    kubislav23 (16th April 2017)

  14. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Just provide the missing code/queries and read some quick MySQL introduction. Stuff like userid should be AUTO_INCREMENT e.g.

    No need to rush, missing the basics is the first reason why you don't reach higher goals in time.

    @Mitch: it's a MySQL function, which needs to be "selected" to call it, here is some example code: https://github.com/kungfooman/cod2_s...stence.gsc#L23
    timescale 0.01

  15. #9
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    I tried this query
    PHP Code:
    CREATE TABLE IF NOT EXISTS `createNewAccount` (
      `
    useridint(10NOT NULL AUTO_INCREMENT,
      `
    usernamevarchar(32) DEFAULT NULL,
      `
    passwordvarchar(32) DEFAULT NULL,
      
    PRIMARY KEY (`userid`)
    ENGINE=MyISAM DEFAULT CHARSET=latin1
    nothing as usal.
    I do !register user pass, console gets
    PHP Code:
    querySELECT createNewAccount('test12''test12') AS `userid
    And instead of getting message ingame saying account created, i get username already excists.
    I try !login test12 test12 i get nothing.
    I checked columns of createnewaccount table, nothing in there. It's like the query ain't working at all.

  16. The Following User Says Thank You to suck000 For This Useful Post:

    kubislav23 (16th April 2017)

  17. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by IzNoGoD View Post
    I see you're using a mysql function. Where is the code for it?

    I see you're using a mysql function. Did you allow the user to execute it?

    I see you're trying to get multiple columns returned from a mysql function. This is not possible.
    This still applies.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

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