Results 1 to 10 of 19

Thread: CoD4 - MySQL problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #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

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

    BlancO (19th September 2013)

Posting Permissions

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