Raised This Month: $ Target: $400
 0% 

[BETA] SQL: Mysql Server has gone away. FIXED. ADDED: Psychostats Module 26/5/10


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
2inspyr
SourceMod Donor
Join Date: Dec 2004
Old 04-12-2010 , 07:37   [BETA] SQL: Mysql Server has gone away. FIXED. ADDED: Psychostats Module 26/5/10
Reply With Quote #1

***********************
PHP FIX - WORKING BETA
***********************
PHP Code:
/*
GUNGAME PHP SQL v2.0(for gungame 2.13 beta) By Bonkaz aKa 2inspyr 

Massive credit to KRIM for the original version and parts of his code which i used.

Gungame PHP SQL is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.

*/ 
you need 2 have the tables setup in your database for this to work, this is only a bridge between the gungame.stats file and your database. Edit the config file to suit your settings, upload to a webserver, IMPORTANT: make sure that whatever folder these file are in is CHMOD 777, if you upload it in its current structure to your public_html it will work as is, but the public will have access to execute the php file. It needs to be setup somewhere public dont have access to and run with CRON to make it secure.

ADDED PSYCHOSTATS MODULE BETA 1.0 26/5/10

for this to work correctly, you will need to have a current installation of psychostats (tested on 3.2 nightly). your gungame tables should be in the same database as your psychostats, this module will use the config from psychostats to connect to the database. upload the files in thier current structure, this will work with the "default" and "default-blue" themes currently.
it will also add a new link "gungame" to the link bar at the top so you can access the ranks.

preview can be seen here on my psychostats
http://www.gigabitgaming.com/ggstats/gungame.php CURRENTLY OFFLINE FOR UPDATING

future:
i will add the gungame rank into the users pages as well as having thier rank displayed on a main page. i might also intergrate it into the main "ranks" page.


********************
AMXX CODE FIX
********************

this code seems to be doing the job.

this is what ive modified:

PHP Code:
stock SQL_ExecuteAndLog(Handle:queryHandle,const queryStr[]=""

    if(!
SQL_Execute(queryHandle)) 
    { 
        static 
error[256]; 
        new 
errnum SQL_QueryError(queryHandle,error,255); 
         
        if(
queryStr[0]) 
        {  
            
log_amx("Could not execute query [%s] -- err #%i [%s]",queryStr,errnum,error); 
        } 
        else 
        { 
            
SQL_GetQueryString(queryHandle,mkQuery,255); 
            
log_amx("Could not execute query [%s] -- err #%i [%s]",mkQuery,errnum,error); 
        } 
         
         
        if(
errnum == 2006)  
        { 
            new 
host[32], user[32], pass[32], dbname[32]; 
            
get_pcvar_string(gg_sql_host,host,31); 
            
get_pcvar_string(gg_sql_user,user,31); 
            
get_pcvar_string(gg_sql_pass,pass,31); 
            
get_pcvar_string(gg_sql_db,dbname,31); 
             
             
            new 
sqlErrorCodesqlError[1024]; 
             
            
tuple SQL_MakeDbTuple(host,user,pass,dbname); 
             
            if(
tuple
            { 
                
db SQL_Connect(tuple,sqlErrorCode,sqlError,1023); 
            } 
             
            if(
db == Empty_Handle
            { 
                
log_amx("Could not connect to database. Error #%i: %s",sqlErrorCode,sqlError); 
                return 
0
            } 
            else 
            { 
                
SQL_Execute(queryHandle
                
log_amx("Error #%i : Reconnected : Resent query [%s]",errnum,queryStr); 
                return 
1
            } 
             
             
        } 
        else 
        { 
            return 
0
        } 
    } 
    return 
1

Original:
PHP Code:
stock SQL_ExecuteAndLog(Handle:queryHandle,const queryStr[]="")
{
    if(!
SQL_Execute(queryHandle))
    {
        static 
error[256];
        new 
errnum SQL_QueryError(queryHandle,error,255);

        if(
queryStr[0]) log_amx("Could not execute query [%s] -- err #%i [%s]",queryStr,errnum,error);
        else
        {
            
SQL_GetQueryString(queryHandle,mkQuery,255);
            
log_amx("Could not execute query [%s] -- err #%i [%s]",mkQuery,errnum,error);
        }

        return 
0;
    }
    return 
1;

basically it allows the plugin to reconnect to the database if it throws the "mysql database has gone away" error and resend the command it failed on, and send the rest through as your now reconnected.
download compiled or uncompiled version below.



cheers
2inspyr
Attached Files
File Type: zip gg_php.zip (2.1 KB, 240 views)
File Type: sma Get Plugin or Get Source (gungame_with_sql.sma - 936 views - 278.3 KB)
File Type: zip Gungame Psychostats Module beta v1.0.zip (5.4 KB, 198 views)
__________________
hmmms........

Last edited by 2inspyr; 08-01-2010 at 00:42.
2inspyr is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode