SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 23/07/2011, 04:23 AM   #1641
nemesis-
Huge Clucker
 
Join Date: Sep 2009
Location: USA
Posts: 231
Reputation: 65
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

If I understand this correctly, mysql_format() does the escaping for you so there's no need to sanitize inputs before using them and formats the string all in one?
nemesis- is offline   Reply With Quote
Old 23/07/2011, 07:40 AM   #1642
[NoV]LaZ
High-roller
 
Join Date: May 2008
Posts: 1,417
Reputation: 90
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Quote:
Originally Posted by nemesis- View Post
If I understand this correctly, mysql_format() does the escaping for you so there's no need to sanitize inputs before using them and formats the string all in one?
Yes.
__________________

Thank you for playing!

It is back online! 176.31.69.249:7799
[NoV]LaZ is offline   Reply With Quote
Old 23/07/2011, 08:23 AM   #1643
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,871
Reputation: 230
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Just put _ there.

Code:
mysql_format(_,.....);
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 23/07/2011, 11:42 AM   #1644
_[HuN]_Epsilon_
Huge Clucker
 
Join Date: Apr 2009
Location: Behind You!
Posts: 265
Reputation: 9
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

I have a 3way problem:

- If I use mysql_ping every second to check the connection, my server crashes.

Code:
[12:47:15] The server has been crashed by mysql_ping at line 15181 in rr.pwn.
[12:47:15] Stack trace of gamemodes\rr.amx (most recent call first):
[12:47:16] #0: (null) (entry point) in rr.pwn
- If I do not use mysql_ping and just refresh the mysql connection (mysql_reconnect), my server doesn't crash, but I get often this message: (Debug.txt)
Code:
[18:41:43] CMySQLHandler::Query(SELECT `job` FROM `jobs` WHERE `name` = "Noah_Vosen") - Successfully executed.

[18:41:43] >> mysql_store_result( Connection handle: 1 )

[18:41:43] CMySQLHandler::StoreResult() - Result was stored.

[18:41:43] >> mysql_num_rows( Connection handle: 1 )

[18:41:43] CMySQLHandler::NumRows() - Returned 1 row(s)

[18:41:43] >> mysql_fetch_int( Connection handle: 1 )

[18:41:43] CMySQLHandler::FetchRow() - Return: 0

[18:41:43] >> mysql_free_result( Connection handle: 1 )

[18:41:43] CMySQLHandler::FreeResult() - Result was successfully free'd.

[18:41:43] >> mysql_reconnect( Connection handle: 1 )

[18:41:43] CMySQLHandler::Disconnect() - Connection was closed.

[18:41:43] CMySQLHandler::Connect() - Can't connect to MySQL server on '91.82.84.98' (10048) (Error ID: 2003)

[18:41:44] >> mysql_format( Connection handle: 1 )

[18:41:44] >> mysql_query( Connection handle: 1 )

[18:41:44] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[18:41:44] >> mysql_store_result( Connection handle: 1 )

[18:41:44] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[18:41:44] >> mysql_num_rows( Connection handle: 1 )

[18:41:44] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[18:41:44] >> mysql_fetch_int( Connection handle: 1 )

[18:41:44] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Connection is dead)

[18:41:44] >> mysql_free_result( Connection handle: 1 )

[18:41:44] CMySQLHandler::FreeResult() - There is nothing to free (Reason: Connection is dead)

[18:41:44] >> mysql_reconnect( Connection handle: 1 )

[18:41:44] CMySQLHandler::Disconnect() - You cannot call this function now. (Reason: Connection is dead)

[18:41:44] CMySQLHandler::Connect() - Connection was successful.

[18:41:44] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[18:41:45] >> mysql_reconnect( Connection handle: 1 )

[18:41:45] CMySQLHandler::Disconnect() - Connection was closed.

[18:41:45] CMySQLHandler::Connect() - Connection was successful.
- If I don't use both, my mysql server goes away.

Code:
[22:45:54] CMySQLHandler::Query(SELECT `user_id` FROM `users` WHERE `name` = 'Maximilien_Maurizio') - Successfully executed.

[22:45:54] >> mysql_store_result( Connection handle: 1 )

[22:45:54] CMySQLHandler::StoreResult() - Result was stored.

[22:45:54] >> mysql_num_rows( Connection handle: 1 )

[22:45:54] CMySQLHandler::NumRows() - Returned 1 row(s)

[22:45:54] >> mysql_free_result( Connection handle: 1 )

[22:45:54] CMySQLHandler::FreeResult() - Result was successfully free'd.

[22:45:54] >> mysql_format( Connection handle: 1 )

[22:45:54] >> mysql_query( Connection handle: 1 )

[22:45:54] CMySQLHandler::Query(UPDATE `users` SET `heal` = 42.527000, `x` = 251.001358,`y` = -158.046692,`z` = 1.570322,`a` = 106.713684,`interior` = 0, `vw` = 0, time = time+39 WHERE `name` = "Maximilien_Maurizio") - Successfully executed.

[22:59:58] >> mysql_free_result( Connection handle: 1 )

[22:59:58] CMySQLHandler::FreeResult() - The result is already empty.

[22:59:58] >> mysql_query( Connection handle: 1 )

[22:59:58] CMySQLHandler::Query(SELECT * FROM `banlist` WHERE `banned` = "Vittorio_Benedetto") - An error has occured. (Error ID: 2006, MySQL server has gone away)

[22:59:58] >> mysql_store_result( Connection handle: 1 )

[22:59:58] CMySQLHandler::StoreResult() - No data to store.

[22:59:58] >> mysql_num_rows( Connection handle: 1 )

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

[22:59:58] >> mysql_free_result( Connection handle: 1 )

[22:59:58] CMySQLHandler::FreeResult() - The result is already empty.

[22:59:58] >> mysql_query( Connection handle: 1 )

[22:59:58] CMySQLHandler::Query(SELECT * FROM `banlist` WHERE `banned` = "Vittorio_Benedetto") - An error has occured. (Error ID: 2006, MySQL server has gone away)

[22:59:58] >> mysql_store_result( Connection handle: 1 )

[22:59:58] CMySQLHandler::StoreResult() - No data to store.

[22:59:58] >> mysql_fetch_row_format( Connection handle: 1 )

[22:59:58] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Empty Result)
_[HuN]_Epsilon_ is offline   Reply With Quote
Old 23/07/2011, 02:15 PM   #1645
Donya
Gangsta
 
Join Date: Mar 2011
Posts: 715
Reputation: 33
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

try onqueryerror and check for connection lost>? then reconnect and redo the query
__________________
[FilterScript]Exception 0xC0000005 at 0x7F120E Protection | OnVehicleMod monitoring. Now Full Protection!

I'm sorry for what was posted earlier, I was hacked.
Donya is offline   Reply With Quote
Old 23/07/2011, 02:22 PM   #1646
_[HuN]_Epsilon_
Huge Clucker
 
Join Date: Apr 2009
Location: Behind You!
Posts: 265
Reputation: 9
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Code:
public OnQueryError(errorid, error[], resultid, extraid, callback[], query[], connectionHandle)
{
	switch(errorid)
	{
		case CR_SERVER_LOST:
		{
		    print("[MYSQL-DEATH]");
		    mysql_reconnect();
		}
	}
}
I tried this, but it doesn't get called.
_[HuN]_Epsilon_ is offline   Reply With Quote
Old 23/07/2011, 02:35 PM   #1647
Donya
Gangsta
 
Join Date: Mar 2011
Posts: 715
Reputation: 33
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

I don't know why your server is disconnecting but add CR_SERVER_GONE_ERROR it might help with the second one
__________________
[FilterScript]Exception 0xC0000005 at 0x7F120E Protection | OnVehicleMod monitoring. Now Full Protection!

I'm sorry for what was posted earlier, I was hacked.
Donya is offline   Reply With Quote
Old 23/07/2011, 04:03 PM   #1648
_[HuN]_Epsilon_
Huge Clucker
 
Join Date: Apr 2009
Location: Behind You!
Posts: 265
Reputation: 9
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Thanks Donya!
Now it tries to reconnect, but the problem is still alive in an other form, see:

Code:
[17:16:59] CMySQLHandler::Query(UPDATE vehicles SET gas=34.9,km=13.590893,health=1000.0,engine=0,lights=1,doors=-1,boot=-1 WHERE carid = 877) - Successfully executed.

[17:16:59] >> mysql_format( Connection handle: 1 )

[17:16:59] >> mysql_query( Connection handle: 1 )

[17:16:59] CMySQLHandler::Query(SELECT `job` FROM `jobs` WHERE `name` = "Sylar_Fukuda") - Successfully executed.

[17:16:59] >> mysql_free_result( Connection handle: 1 )

[17:16:59] CMySQLHandler::FreeResult() - Result was successfully free'd.

[17:16:59] >> mysql_store_result( Connection handle: 1 )

[17:16:59] CMySQLHandler::StoreResult() - Result was stored.

[17:16:59] >> mysql_num_rows( Connection handle: 1 )

[17:16:59] CMySQLHandler::NumRows() - Returned 0 row(s)

[17:17:01] >> mysql_query( Connection handle: 1 )

[17:17:01] CMySQLHandler::Query(UPDATE vehicles SET gas=34.9,km=13.590893,health=1000.0,engine=1,lights=1,doors=-1,boot=-1 WHERE carid = 877) - An error has occured. (Error ID: 2006, MySQL server has gone away)

[17:17:01] OnQueryError() - Called.

[17:17:01] >> mysql_reconnect( Connection handle: 1 )

[17:17:01] CMySQLHandler::Disconnect() - Connection was closed.

[17:17:02] CMySQLHandler::Connect() - Can't connect to MySQL server on '91.82.84.98' (10061) (Error ID: 2003)

[17:17:05] >> mysql_query( Connection handle: 1 )

[17:17:05] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[17:17:05] >> mysql_format( Connection handle: 1 )

[17:17:05] >> mysql_query( Connection handle: 1 )

[17:17:05] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[17:17:05] >> mysql_free_result( Connection handle: 1 )

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

[17:17:05] >> mysql_store_result( Connection handle: 1 )

[17:17:05] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[17:17:05] >> mysql_num_rows( Connection handle: 1 )

[17:17:05] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[17:17:05] >> mysql_fetch_int( Connection handle: 1 )

[17:17:05] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Connection is dead)

[17:17:05] >> mysql_free_result( Connection handle: 1 )

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

[17:17:07] >> mysql_format( Connection handle: 1 )

[17:17:07] >> mysql_query( Connection handle: 1 )

[17:17:07] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
_[HuN]_Epsilon_ is offline   Reply With Quote
Old 24/07/2011, 08:21 PM   #1649
HP
Big Clucker
 
HP's Avatar
 
Join Date: Mar 2011
Posts: 95
Reputation: 3
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Quote:
Originally Posted by Sergei View Post
Just put _ there.

Code:
mysql_format(_,.....);
I don't think you can use the underscore, you would get an error about the argument not having a default value.


PS. Thanks for the update and goodbye GetEscName().
HP is offline   Reply With Quote
Old 24/07/2011, 08:24 PM   #1650
[NoV]LaZ
High-roller
 
Join Date: May 2008
Posts: 1,417
Reputation: 90
Default Re: [REL] MySQL Plugin R6-2 - 17/07/11

Quote:
Originally Posted by HP View Post
I don't think you can use the underscore
Yes you can.
__________________

Thank you for playing!

It is back online! 176.31.69.249:7799
[NoV]LaZ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
****** Project: Glass int3s0 Everything and Nothing 99 26/02/2013 04:22 PM
MySQL Plugin R5 plugin problem dud Scripting Help 12 05/12/2011 06:28 PM
Strikens Mysql vs BlueG's Mysql plugin PrawkC Scripting Help 4 30/09/2011 10:30 AM
[help][plugin] Can't load mysql plugin mariomako Help Archive 8 16/07/2011 02:37 PM
mysql plugin. loading plugin failed ikkentim Help Archive 2 10/02/2011 02:32 PM


All times are GMT. The time now is 06:03 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.