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

Thread: mysql init

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    mysql init

    Hi all,

    I want to setup mysql
    Code:
    init()
    {
        //get your host, user, pass, db, port here
        level.mysql = mysql_reuse_connection();
    	host = getcvar("mysql_host");
    	user = getcvar("mysql_user");
    	pass = getcvar("mysql_password");
    	db = getcvar("mysql_database");
        if(!isDefined(level.mysql))
            level.mysql = initMySQL(host, user, pass, db, 3306);
        initAsyncMySQL(host, user, pass, db, 3306);
    }
    in the config I have (which is loaded)
    Code:
    set mysql_host "hostname"
    set mysql_user "username"
    set mysql_password "pw"
    set mysql_database "dbname"
    This aint working, I get a segmentation fault.
    But when I directly write it in the initmysql function, it is working.
    Code:
    init()
    {
        //get your host, user, pass, db, port here
        level.mysql = mysql_reuse_connection();
    	host = getcvar("mysql_host");
    	user = getcvar("mysql_user");
    	pass = getcvar("mysql_password");
    	db = getcvar("mysql_database");
        if(!isDefined(level.mysql))
            level.mysql = initMySQL(hostname, username, pw, dbname, 3306);
        initAsyncMySQL(hostname, username, pw, dbname, 3306);
    }
    What could be the problem?

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

    kung foo man (16th August 2018)

  3. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Code:
    initMySQL
    initAsyncMySQL
    what this?

    Are you sure that the cvars are not null? (Yes, i know: libcod checks params, but look what you get there at the moment of call the function)
    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

  4. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    those are functions from standard mysql script from here somewhere

  5. #4
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Is it good idea to store those credentials in .cfg file?

  6. #5
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Quote Originally Posted by Whiskas View Post
    Is it good idea to store those credentials in .cfg file?
    where else?

  7. #6
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Quote Originally Posted by Ni3ls View Post
    where else?
    Directly in init function

  8. #7
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I thought it was more secure to write in a random cfg

  9. #8
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Getting them from cvars works for me.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  10. #9
    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
    Quote Originally Posted by maxdamage99 View Post
    Code:
    initMySQL
    initAsyncMySQL
    what this?
    IzNoGoDs, high level of abstraction from C API for easier coding, once you got the pieces together:

    https://killtube.org/showthread.php?...ll=1#post13719
    https://github.com/iznogod/OSJH/blob...H/jh/mysql.gsc

    My example test script kinda as raw as it gets, write-your-own-wrapper style, probably nice for testing:

    https://github.com/kungfooman/cod2_s..._debugging.gsc

    I don't know if anybody made changes to the MySQL C/GSC API aswell in newer libcod versions, which might cause problems. Which version are you using?

    In a "perfect/nonlazy/paid" world, each breaking API change should force a new internal version to libcod's subcomponents like the MySQL system. So we could just add Mayor/Minor versions and quickly see if libcod/scripts are compatible.
    timescale 0.01

  11. #10
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    https://github.com/iznogod/OSJH/blob...H/jh/mysql.gsc

    Feel free to use. Some example usages also shown in the related files.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

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

    kung foo man (16th August 2018)

Posting Permissions

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