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

Thread: CoD4 - MySQL problem

  1. #1
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts

    CoD4 - MySQL problem

    I've got a problem with MySQL. I don't know what's wrong. After this MySQL is still the same. There's no players table.

    .gsc script
    PHP Code:
        mysql std\mysql::mysql_real_connect(std\mysql::mysql_init(), level.mysqlAdresslevel.mysqlUserlevel.mysqlPasslevel.mysqlDblevel.mysqlPort)

        
    std\mysql::mysql_query(mysql"CREATE TABLE players (id int NOT NULL AUTO_INCREMENT, name varchar(30), score varchar(12), kills varchar(9), PRIMARY KEY(id))");
        
    std\mysql::mysql_close(mysql); 
    .sh script
    Code:
    cd /home/cod4/zombie
    LD_LIBRARY_PATH="/home/libcod/mysql" LD_PRELOAD="/home/libcod/libcod4_1_7.so" ./cod4x17a_lnxded +set dedicated "2" +set net_port "28961" +set fs_basepath "/home/cod4/zombie/" +set fs_game "mods/nlMod" +exec nlMod.cfg +map_rotate
    Contents of /home/libcod:
    Code:
    root@blanco:/home/libcod# ls
    libastar.so     libcod2_1_2.so  libcod2.so      mysql
    libcod1_1_5.so  libcod2_1_3.so  libcod4_1_7.so
    Contents of /home/libcod/mysql:
    Code:
    root@blanco:/home/libcod/mysql# ls
    libmysqlclient.a     libmysqlclient.so  libmysql.so.16
    libmysqlclient_r.so  libmysql.so        libmysql.so.16.0.0
    Last edited by BlancO; 19th September 2013 at 20:13.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    It might be everything, best is to check always for errors and printing them:

    PHP Code:
    #include std\mysql;

    mysql_test()
    {
        
    host getcvar("mysql_host");
        
    user getcvar("mysql_user");
        
    pass getcvar("mysql_pass");
        
    db getcvar("mysql_db");
        
    port getcvarint("mysql_port");
        
        
        
    mysql mysql_init();
        
        if ( ! 
    isDefined(mysql))
        {
            
    std\io::println("mysql not defined!");
            return;    
        }

        
    std\io::print("mysql=" + ("2"+2) + "\n");
        
        
    ret mysql_real_connect(mysqlhostuserpassdbport);
        if (!
    ret)
        {
            
    std\io::print("errno="+mysql_errno(mysql) + " error=''"+mysql_error(mysql) + "''\n");
            
    mysql_close(mysql);
            return 
    0;
        }
        
        
    std\io::print("affected_rows="+mysql_affected_rows(mysql)+"\n");
        
        
        
        
    name "fo\"0'z0`r"// all user-input is evil!
        
    name mysql_real_escape_string(mysqlname); // so escape it :)
        
        
    theQuery "SELECT * FROM players";
        
    theQuery "SELECT \""+name+"\" as first,2 as second,3 as third UNION SELECT 11,22,33";
        
        
    std\io::print(theQuery);
        
        
    ret mysql_query(mysqltheQuery);
        if (
    ret != 0)
        {
            
    std\io::print("errno="+mysql_errno(mysql) + " error=''"+mysql_error(mysql) + "''\n");
            
    mysql_close(mysql);
            return 
    0;
        }
        
        
    result mysql_store_result(mysql);
        
        
    std\io::print("num_rows="+mysql_num_rows(result) + " num_fields="+mysql_num_fields(result)+"\n");
        
        
    mysql_field_seek(result0);
        while (
    1)
        {
            
    result_name mysql_fetch_field(result);
            if (!
    isString(result_name))
                break;
            
    std\io::print("field-name=" result_name+"\n");
        }
        
        while (
    1)
        {
            
    row mysql_fetch_row(result);
            if (!
    isDefined(row))
            {
                
    //std\io::print("row == undefined\n");
                
    break;
            }
            
    output "";
            for (
    i=0i<row.sizei++)
                
    output += row[i] + " ";
            
    std\io::print(output+"\n");
        }
        
        
    mysql_free_result(result);
        
        
    mysql_close(mysql);
                

    Example from: http://killtube.org/downloads/cod2/e..._debugging.gsc
    timescale 0.01

  3. The Following User Says Thank You to kung foo man For This Useful Post:

    BlancO (19th September 2013)

  4. #3
    Private
    Join Date
    Nov 2012
    Location
    Denmark, where else
    Posts
    27
    Thanks
    5
    Thanked 13 Times in 6 Posts
    Do you have a mysql database? if not then here we go.

    Before installing Mysql, make sure your repositories are up to date:

    apt-get update

    Now you need Apache:

    apt-get install apache2

    To install Mysql, enter terminal or screen and type in these commands:

    apt-get install mysql-server

    Follow the instructions.
    If you miss the chance to set the password then you can always do it within the mysql shell.

    Run the mysql setup script:

    mysql_secure_installation

    The prompt will ask you for your current root password. Type it in.

    Once again follow the instructions and remember pressing N is for No and Y for yes.

    INSTALLING PHP? not sure if it's necessary but here we go:

    apt-get install php5 php-pear php5-suhosin php5-mysql

    Answer YES twice and it will install itself.

    Finish up by restarting apache:

    service apache2 restart
    Last edited by Sense; 19th September 2013 at 20:36.
    Dont drink and drive, smoke and fucking fly

  5. The Following 3 Users Say Thank You to Sense For This Useful Post:

    BlancO (19th September 2013),kung foo man (19th September 2013),YuriJurek (19th September 2013)

  6. #4
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Well all of that is already installed no worry about such a basic stuff

  7. #5
    Private
    Join Date
    Nov 2012
    Location
    Denmark, where else
    Posts
    27
    Thanks
    5
    Thanked 13 Times in 6 Posts
    Quote Originally Posted by YuriJurek View Post
    Well all of that is already installed no worry about such a basic stuff
    Just tried to help, show a little gratitude instead..
    Dont drink and drive, smoke and fucking fly

  8. #6
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts
    I think it's something wrong with libcod. I even don't receive any of these "std\io::print". I have mysql-server, apache2, php5 installed.

  9. #7
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    When you start the server, you should see something like this:

    Code:
    > [WARNING] Compiled for: 210
    Compiled: Sep 17 2013 23:08:19
    > [INFO] value of closer=08111d32
    > [PLUGIN LOADED]
    CoD2 MP 1.0 build linux-i386 Oct 24 2005
    ----- FS_Startup -----
    Current search path:
    /home/k_deathrun/zombots
    /home/k_deathrun/main/iw_14.iwd (4038 files)
    /home/k_deathrun/main/iw_13.iwd (22624 files)
    /home/k_deathrun/main/iw_12.iwd (1016 files)
    /home/k_deathrun/main/iw_11.iwd (1462 files)
    /home/k_deathrun/main/iw_10.iwd (1936 files)
    /home/k_deathrun/main/iw_09.iwd (2142 files)
    /home/k_deathrun/main/iw_08.iwd (2723 files)
    /home/k_deathrun/main/iw_07.iwd (3384 files)
    /home/k_deathrun/main/iw_06.iwd (990 files)
    /home/k_deathrun/main/iw_05.iwd (928 files)
    /home/k_deathrun/main/iw_04.iwd (698 files)
    /home/k_deathrun/main/iw_03.iwd (26 files)
    /home/k_deathrun/main/iw_02.iwd (40 files)
    /home/k_deathrun/main/iw_01.iwd (16 files)
    /home/k_deathrun/main/iw_00.iwd (102 files)
    /home/k_deathrun/main
    /home/k_deathrun/raw
    /home/k_deathrun/raw_shared
    /home/k_deathrun/devraw
    /home/k_deathrun/devraw_shared
    Do you see the [PLUGIN LOADED]? It might can't find the mysql-dependency
    timescale 0.01

  10. #8
    Private First Class YuriJurek's Avatar
    Join Date
    Jun 2013
    Posts
    219
    Thanks
    152
    Thanked 88 Times in 47 Posts
    Quote Originally Posted by Sense View Post
    Just tried to help, show a little gratitude instead..
    I mean no disrespect maybe it just sounds so a little bit.

  11. #9
    Private
    Join Date
    Feb 2013
    Location
    Poland
    Posts
    32
    Thanks
    33
    Thanked 27 Times in 8 Posts
    I can't see "[PLUGIN LOADED]"...

    .sh file
    Code:
    export LD_LIBRARY_PATH="/home/cod4/server/libs:/home/cod4/server/libs/mysql"
    export LD_PRELOAD="/home/cod4/server/libs/libcod4_1_7.so"
    
    cd /home/cod4/server
    ./cod4_lnxded +set dedicated "2" +set net_port "28961" +set fs_basepath "/home/cod4/server" +set fs_homepath "/home/cod4/server" +set fs_game "mods/nl_zom" +exec zom.cfg +map_rotate

  12. #10
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    cod4_lnxded is a start-script, call cod4_lnxded_bin directly
    timescale 0.01

Posting Permissions

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