[Plugin] [REL] MySQL Plugin (Now on github!)

Up, please.
Reply

I have one problem here...

Result from phpmyadmin:

Quote:

Result from plugin:

Quote:

Code (pastebin here):

Код:
LoadDroppedItems()
{
	new query[1024];
	mysql_format(MySQL, query, sizeof(query), "SELECT * FROM `items` WHERE `owner` = '-1';");
	mysql_tquery(MySQL, query, "OnDroppedItemsLoad", "");
	return 1;
}

public OnDroppedItemsLoad()
{
	print("\n\n---------------------------");
	new rows = cache_num_rows();
	printf("num of rows = %d", rows);
	
	for(new d; d < rows; d++)
	{
		static id, model, amount, Float:x, Float:y, Float:z;
		id = cache_get_field_content_int(d, "id", MySQL);
		model = cache_get_field_content_int(d, "model", MySQL);
		amount = cache_get_field_content_int(d, "amount", MySQL);
		x = cache_get_field_content_float(d, "coord_x", MySQL);
		y = cache_get_field_content_float(d, "coord_y", MySQL);
		z = cache_get_field_content_float(d, "coord_z", MySQL);		
		CreateDroppedItem(id, model, amount, x, y, z);
		
		#if defined DEBUGMSG
		new string[128];
		format(string, sizeof(string), "Loop %d retrieved item_id = %d and item_model = %d",d, id, model);
		print(string);
		#endif
	}
	print("---------------------------\n\n");
	return 1;
}
@EDIT: mysql_log


Код:
[16:10:08] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_int - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
[16:10:09] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('2')
[16:10:09] [ERROR] cache_get_field_content_float - invalid datatype
Reply

Hello !

I have a query:

pawn Код:
mysql_format(MySQLConnect, query, 512, "SELECT FROM_UNIXTIME(`Timestamp`, '%%d-%%m-%%Y а %%H:%%I:%%S') AS Timestamp, Admin, Raison FROM `warns` WHERE SQLid = %d", PlayerInfo[playerid][ID]);
    mysql_tquery(MySQLConnect, query, "Show", "ii", playerid, playerid);
My timestamp = 1421947410.

With the website http://www.timestamp.fr/: 1421947410 = 22/1/2015 а 18:23:30.

But, with my query, the result = 22-01-2015 а 18:06:30...

Why?

++
Reply

Not quite sure if it's allowed to ask questions not related to this plugin here.
Reply

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
Not quite sure if it's allowed to ask questions not related to this plugin here.
Its not only questions, its not scripting help only, it can be maybe an bug report idk...
Reply

Never put quotes around numbers (it should be -1, not '-1').
Does CreateDroppedItem do anything with the MySQL plugin?
Should you not put the connection handle in cache_num_rows? Such as cache_num_rows(MySQL).
Try using cache_get_data instead of cache_num_rows.
Reply

Quote:
Originally Posted by Slice
Посмотреть сообщение
Never put quotes around numbers (it should be -1, not '-1').
Does CreateDroppedItem do anything with the MySQL plugin?
Should you not put the connection handle in cache_num_rows? Such as cache_num_rows(MySQL).
Try using cache_get_data instead of cache_num_rows.
Never put quotes around numbers (it should be -1, not '-1'): Done, i removed but nothing changed :/

Does CreateDroppedItem do anything with the MySQL plugin?: Yes, found the bug here.

Should you not put the connection handle in cache_num_rows? Such as cache_num_rows(MySQL): Yes but i actually only use one conenctionhandle (the default, btw, i already added and tested it too)...

Try using cache_get_data instead of cache_num_rows.: @EditІ Tried but still not working, i have the same problem, cache returns me empty values on get_field_content_stuff after the first row even when i change the row index with loop (and get errors on mysql_log)...


Problem solved, i forgot to remove this on create dropped item:

Код:
new query[512];
mysql_format(MySQL, query, sizeof(query), "UPDATE `items` SET `owner` = -1, `coord_x` = '%f', `coord_y` = '%f', `coord_z` = '%f' WHERE `id` = %d;",x, y, z, itemid);
mysql_tquery(MySQL, query, "", "");
Thanks Mr.Slice
Reply

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
Not quite sure if it's allowed to ask questions not related to this plugin here.
Quote:
Originally Posted by n0minal
Посмотреть сообщение
Its not only questions, its not scripting help only, it can be maybe an bug report idk...
He was referring to Baltimore.
Regarding your problem, enable debug logging ('LOG_ALL' in function 'mysql_log') and post that output here (don't forget to include the log messages regarding the call to mysql_tquery).

EDIT: yeah, nvm
Reply

Fixed.

Other:

I have this error:

Код:
[22:13:08] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Numero", connection: 1
[22:13:08] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Numero")
[22:13:08] [ERROR] cache_get_field_content_int - invalid datatype
In my code:

pawn Код:
new Numero = cache_get_field_content_int(i, "Numero");
In my database:

pawn Код:
`Numero` bigint(20) NOT NULL,
THX
Reply

Quote:
Originally Posted by Baltimore
Посмотреть сообщение
Fixed.

Other:

I have this error:

Код:
[22:13:08] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Numero", connection: 1
[22:13:08] [WARNING] CMySQLResult::GetRowDataByName - field not found ("Numero")
[22:13:08] [ERROR] cache_get_field_content_int - invalid datatype
In my code:

pawn Код:
new Numero = cache_get_field_content_int(i, "Numero");
In my database:

pawn Код:
`Numero` bigint(20) NOT NULL,
THX
Change that bigint to just int. That function returns int types only.
Reply

Quote:
Originally Posted by kirk
Посмотреть сообщение
Change that bigint to just int. That function returns int types only.
Not work ^^
Reply

Quote:
Originally Posted by Baltimore
Посмотреть сообщение
Not work ^^
Make sure you are on the proper table or check that name, probably you have ґNъmeroґ.
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
He was referring to Baltimore.
Regarding your problem, enable debug logging ('LOG_ALL' in function 'mysql_log') and post that output here (don't forget to include the log messages regarding the call to mysql_tquery).

EDIT: yeah, nvm
I was spamming queries, solved problem Mr.maddinat0r, thanks ^^
Reply

The query doesn't work because it's completely invalid. You need to go study SQL Language.
Reply

If you refer to the semicolon ";" is present.

Moreover, in phpmyadmin, if I do the query, execute it well.

A frame appears, but it encarde as:

NumeroSuppr
NumeroSupprTo
Numero
NumeroTo
Reply

UP, please.
Reply

Please can someone fix the links or re-upload them, I need windows and then Linux ones urgently
Reply

Quote:
Originally Posted by MotherDucker
Посмотреть сообщение
Please can someone fix the links or re-upload them, I need windows and then Linux ones urgently
https://github.com/pBlueG/SA-MP-MySQL/releases

They're fine.
Reply

Quote:
Originally Posted by iZN
Посмотреть сообщение
Im sure he requested R6 and R7 like i did few posts above...
Reply

Links outdated?
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)