PDA

View Full Version : [Help][MySQL]MySQL query unsuccessful.


Timmi
31/12/2011, 02:16 PM
So um, I've got a small problem. Let me try to make it short, so here it is:

When I start the server, I get the message "[MySQL] Connection successful!" in console. But when I join the server, and try to register or something, it gives me "[MySQL] Query Unsuccessful. (blah blah blah)". No idea why. I am using G-stylz/whatever's MySQL script, and I am on debian 5. if I load 'mysql.so', I get "libmysqlclient.so.15: cannot open shared [..]", but if I load 'mysql_debian.so', I dont get any such errors. (libmysqlclient.so.15: cannot open shared [..])

Example: [13:23:34] [MYSQL] MySQL query unsuccessful. (INSERT INTO `playerjoins` (`joinid`, `player`, `ip`, `date`) values(NULL, 'T1mm1[XA]', '127.0.0.1', NOW()))

Script: stock LogJoin(player[], ip[])
{
format(szQuery, sizeof(szQuery), "INSERT INTO `playerjoins` (`joinid`, `player`, `ip`, `date`) values\
(NULL, '%s', '%s', NOW())", player, ip);
SendQuery(szQuery);
return true;
}

mysql_debug.txt:

[13:23:34] ---------------------------
[13:23:34] MySQL Debugging activated (12/31/11)
[13:23:34] ---------------------------
[13:23:34]
[13:23:34] >> mysql_ping( Connection handle: 1 )
[13:23:34] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:23:34] >> mysql_ping( Connection handle: 1 )
[13:23:34] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:23:34] >> mysql_query( Connection handle: 1 )
[13:23:34] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
[13:23:34] >> mysql_ping( Connection handle: 1 )
[13:23:34] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:23:34] >> mysql_query( Connection handle: 1 )
[13:23:34] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
[13:23:34] >> mysql_store_result( Connection handle: 1 )
[13:23:34] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)
[13:23:34] >> mysql_num_rows( Connection handle: 1 )
[13:23:34] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[13:23:34] >> mysql_ping( Connection handle: 1 )
[13:23:34] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:32:43] >> mysql_ping( Connection handle: 1 )
[13:32:43] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:32:43] >> mysql_query( Connection handle: 1 )
[13:32:43] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
[13:32:43] >> mysql_store_result( Connection handle: 1 )
[13:32:43] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)
[13:32:43] >> mysql_num_rows( Connection handle: 1 )
[13:32:43] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[13:32:43] >> mysql_free_result( Connection handle: 1 )
[13:32:43] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)
[13:43:56] >> mysql_ping( Connection handle: 1 )
[13:43:56] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)
[13:43:56] >> mysql_query( Connection handle: 1 )
[13:43:56] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
[13:43:56] >> mysql_store_result( Connection handle: 1 )
[13:43:56] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)
[13:43:56] >> mysql_num_rows( Connection handle: 1 )
[13:43:56] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[13:43:56] >> mysql_free_result( Connection handle: 1 )
[13:43:56] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

That's it.. Can you help me, please? Thank you in advance.

PS: I am using DrPepper's gm, PTPM v5.9

WooTFTW
31/12/2011, 02:32 PM
Are you even connected to the database?

Timmi
31/12/2011, 02:43 PM
I'm pretty sure I am. I've entered the host/dbname/password/username.

PS:

public mysql_start()
{
if (mysql_connect(DBHOST, DBUSER, DBNAME, DBPASS))
{
mysql_debug(1);
print("[MYSQL] Connection successful!");
}
else
{
print("[MYSQL] There was an error connecting to the MYSQL server");
IRC_GroupSay(gGroupID, "IRC_Channel", "[MYSQL] There was an error connecting to the MYSQL server");
}
return 1;
}

MasterB
31/12/2011, 03:25 PM
server log?? does it actually say "[MYSQL] Connection successful!"???

Timmi
01/01/2012, 03:38 AM
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3d, (C)2005-2011 SA-MP Team

[03:29:24] filterscripts = "" (string)
[03:29:24]
[03:29:24] Server Plugins
[03:29:24] --------------
[03:29:24] Loading plugin: irc.so
[03:29:24]

*** IRC Plugin v1.4.2 by Incognito loaded ***

[03:29:24] Loaded.
[03:29:24] Loading plugin: sscanf.so
[03:29:24]

[03:29:24] ===============================

[03:29:24] sscanf plugin loaded.

[03:29:24] (c) 2009 Alex "******" Cole

[03:29:24] ===============================

[03:29:24] Loaded.
[03:29:24] Loading plugin: mysql_debian.so
[03:29:24]

> MySQL plugin R6 successfully loaded.

[03:29:24] Loaded.
[03:29:24] Loaded 3 plugins.

[03:29:24]
[03:29:24] Ban list
[03:29:24] --------
[03:29:24] Loaded: samp.ban
[03:29:24]
[03:29:24]
[03:29:24] Filterscripts
[03:29:24] ---------------
[03:29:24] Loaded 0 filterscripts.

[03:32:33] [MYSQL] Connection successful!
[03:32:33] ================================================== ========
[03:32:33] game mode stuff here
[03:32:33] credits etc
[03:32:33] irc bots connected or not
[03:32:33] blah blah blah
[03:32:33] blah blah blah
[03:32:33] blah blah blah
[03:32:33] ================================================== ========
[03:32:33] Number of vehicle models: 118

[HiC]TheKiller
01/01/2012, 05:55 AM
mysql_connect returns the connection handle, not if it's successful or not. Use MySQL ping to check if the connection to the database was successful.

Timmi
01/01/2012, 06:32 AM
Script:


public CheckSQL()
{
new bool:connected;
if (!mysql_ping())
{
connected = false;
}
else
{
connected = true;
}
if (connected == false)
{
print("[MYSQL] Lost connection to MYSQL server, Reconnecting..");
mysql_start();
}
return 1;
}

mysql.txt:



[06:19:41] >> mysql_ping( Connection handle: 1 )

[06:19:41] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

Kar
01/01/2012, 06:40 AM
put mysql_start(); in OnGameModeInit and

public mysql_start()
{
mysql_debug(1);
if (mysql_connect(DBHOST, DBUSER, DBNAME, DBPASS))
{
print("[MYSQL] Connection successful!");
}
else
{
print("[MYSQL] There was an error connecting to the MYSQL server");
IRC_GroupSay(gGroupID, "IRC_Channel", "[MYSQL] There was an error connecting to the MYSQL server");
}
return 1;
}

Timmi
01/01/2012, 06:55 AM
[12:18:47]

[12:18:47] ---------------------------

[12:18:47] MySQL Debugging activated (01/01/12)

[12:18:47] ---------------------------

[12:18:47]

[12:18:47] >> mysql_connect( )

[12:18:47] CMySQLHandler::CMySQLHandler() - constructor called.

[12:18:47] CMySQLHandler::CMySQLHandler() - Connecting to "176.9.81.250" | DB: "derp_ptpm" | Username: "derp_ptpm" ...

[12:19:08] CMySQLHandler::Connect() - Lost connection to MySQL server during query (Error ID: 2013)

[12:19:08]

[12:19:08] ---------------------------

[12:19:08] MySQL Debugging activated (01/01/12)

[12:19:08] ---------------------------

[12:19:08]

[12:19:08]

[12:19:08] ---------------------------

[12:19:08] MySQL Debugging activated (01/01/12)

[12:19:08] ---------------------------

[12:19:08]

[12:19:08] >> mysql_connect( )

[12:19:29] CMySQLHandler::Connect() - Lost connection to MySQL server during query (Error ID: 2013)

[12:21:22]

[12:21:22] ---------------------------

[12:21:22] MySQL Debugging activated (01/01/12)

[12:21:22] ---------------------------

[12:21:22]

[12:21:22] >> mysql_ping( Connection handle: 1 )

[12:21:22] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:22] >> mysql_ping( Connection handle: 1 )

[12:21:22] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:22] >> mysql_query( Connection handle: 1 )

[12:21:22] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[12:21:22] >> mysql_ping( Connection handle: 1 )

[12:21:22] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:22] >> mysql_query( Connection handle: 1 )

[12:21:22] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[12:21:22] >> mysql_store_result( Connection handle: 1 )

[12:21:22] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[12:21:22] >> mysql_num_rows( Connection handle: 1 )

[12:21:22] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[12:21:22] >> mysql_ping( Connection handle: 1 )

[12:21:22] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:37]

[12:21:37] ---------------------------

[12:21:37] MySQL Debugging activated (01/01/12)

[12:21:37] ---------------------------

[12:21:37]

[12:21:37] >> mysql_ping( Connection handle: 1 )

[12:21:37] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:37] >> mysql_ping( Connection handle: 1 )

[12:21:37] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:37] >> mysql_query( Connection handle: 1 )

[12:21:37] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[12:21:37] >> mysql_ping( Connection handle: 1 )

[12:21:37] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:21:37] >> mysql_query( Connection handle: 1 )

[12:21:37] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[12:21:37] >> mysql_store_result( Connection handle: 1 )

[12:21:37] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[12:21:37] >> mysql_num_rows( Connection handle: 1 )

[12:21:37] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[12:21:37] >> mysql_ping( Connection handle: 1 )

[12:21:37] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[12:23:12] CMySQLHandler::~CMySQLHandler() - deconstructor called.

[12:23:12] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[12:23:12] CMySQLHandler::Disconnect() - You cannot call this function now. (Reason: Connection is dead)


Still no luck. :<

vent
01/01/2012, 11:43 AM
And now you should change the password at your MySQL server.

Timmi
01/01/2012, 11:59 AM
Change it? Why? Huh?

spedico
01/01/2012, 12:08 PM
Because it's visible in the log file you posted. :F

Timmi
01/01/2012, 12:30 PM
I... I dont think so.. lol

Timmi
01/01/2012, 02:59 PM
Hello guys. Thank you all for your help. But Kar's idea somehow worked, and I was hosting MySQL on other server which was differ than SA:MP running server, after hosting MySQL on same server as SA:MP's the problem is fixed. Once again, thank you all. :)

Kar
01/01/2012, 03:01 PM
USE mysql_debug(1); ONCE. in OnGameModeInit

ONCE you are connected, all you need to do is

if (mysql_ping() == -1) mysql_reconnect();

use mysql_start(); ONCE only in OnGameModeInit