Strange error
#1

if someone logs in after the server has been empty for a while I get this error and the server close

Код:
[14:46:59] MySQL Error (0): Could not execute query. MySQL server has gone away.
[14:46:59]  SQL: SELECT `UserID` FROM `Accounts` WHERE `Username` = 'Admin_Teller'
[14:46:59] MySQL Error (0): Function: 'mysql_store_result' called when no prior query executed.. MySQL server has gone away.
Reply
#2

You clearly have no database connection active. Make sure you reconnect to the database before executing a query.
Reply
#3

Which version of MySQL plugin are you using? Did you enabled auto reconnecting?

Post some code
Reply
#4

Check out your database name and script
if database name is for example UserID and in script is used as userid then it wont connect to the database they must be the same
check script and change ur database name
Reply
#5

How do I enable auto reconnecting?
Reply
#6

There is no auto-reconnect in this extremely outdated version of the plugin. If what your signature says is true then I don't know why you still bother with such outdated stuff; new projects should use the new standards.
Reply
#7

If what Vince said is true, then you need to make a reconnect function every 1440 seconds, since database connection is lost after 1440 seconds, and that would be like.

pawn Код:
#define MYSQL_HOST                          ""
#define MYSQL_USER                          ""
#define MYSQL_PASS                          ""
#define MYSQL_BASE                          ""

new db_handle;

forward MYSQL_Reconnect();
public MYSQL_Reconnect() {
    if(mysql_errno(db_handle)) {
        db_handle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_BASE, MYSQL_PASS, 3306);
    }
    return 1;
}

public OnGameModeInit() {
    db_handle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_BASE, MYSQL_PASS, 3306);
    SetTimer("MYSQL_Reconnect", 1440000, true);
    return 1;
}
you need to set values for database defines.

edit: on gamemode initiation, you connect to your database and start the reconnect timer. when timer reaches 1440 seconds(1440000ms), it checks connection, if it's not connected, then it reconnects, if it's connected then it does nothing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)