SA-MP Forums Archive
[Ajuda] qual problema no codigo? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] qual problema no codigo? (/showthread.php?tid=651034)



qual problema no codigo? - iSoaD - 12.03.2018

pessoal estou comeзando a mexer em mysql agora e nгo estou conseguindo resolver meu problema.
nos logs do servidor dб isso:

Код:
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:19:22 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_format - invalid connection handle (id: 0)
[22:20:16 03/11/18] [ERROR] mysql_tquery - invalid connection handle (id: 0)
meu cуdigo
Код:
forward PlayerConnected(playerid);
public PlayerConnected(playerid)
{
	if (!IsPlayerConnected(playerid))
	    return 0;

	static
	    rows,
	    fields;

    cache_get_data(rows, fields, Conexao);

	if (!rows)
	{
		static query[160];

		mysql_format(Conexao, query, sizeof(query), "INSERT INTO `players` (`playerName`) VALUES('%s')", ReturnName(playerid));
		return mysql_tquery(Conexao, query,"","");
	}

	pCampLD[playerid] = cache_get_field_int(0, "campID");
	pCampID[playerid] = cache_get_field_int(0, "playerCampID");
	pStationID[playerid] = cache_get_field_int(0, "playerStationID");
	pCampSuccessor[playerid] = cache_get_field_int(0, "playerCampSuccessor");
 	pObjects[playerid] = cache_get_field_int(0, "playerObjects");
	return 1;
}

stock connectvarsbase(playerid)
{
	pCamps[playerid] = 1;
	pCampID[playerid] = -1;
	pEditAntenna[playerid] = -1;
	pAntennas[playerid] = 1;
	pStationID[playerid] = -1;
	pActualDistance[playerid] = 0.0;
	pCampInvited[playerid] = -1;
	pInvitedLeader[playerid] = INVALID_PLAYER_ID;
	pCampSuccessor[playerid] = -1;

	pSelected[playerid] = -1;
	pObjects[playerid] = 999999;

	new Query[70];

	mysql_format(Conexao, Query, sizeof(Query), "SELECT * FROM `players` WHERE `playerName` = '%s'", ReturnName(playerid));
	mysql_tquery(Conexao, Query, "PlayerConnected", "d", playerid);

return 1;
}



Re: qual problema no codigo? - PowerMwK - 14.03.2018

acho que falta a tabela rows.


Re: qual problema no codigo? - F1N4L - 14.03.2018

Quote:
Originally Posted by PowerMwK
Посмотреть сообщение
acho que falta a tabela rows.
Isso nгo tem relaзгo nenhuma ao problema...

@TOPIC

https://sampwiki.blast.hk/wiki/MySQL#mysql_connect


Re: qual problema no codigo? - PowerMwK - 14.03.2018

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Isso nгo tem relaзгo nenhuma ao problema...

@TOPIC

https://sampwiki.blast.hk/wiki/MySQL#mysql_connect
Pois pois, responda antes kk


Re: qual problema no codigo? - F1N4L - 14.03.2018

Quote:
Originally Posted by PowerMwK
Посмотреть сообщение
Pois pois, responda antes kk
Aparentemente a variбvel Conexao nгo tem nenhuma conexгo vбlida, ou seja, informaзхes de login na base de dados estгo invбlidas.
Se certifique que as informaзхes de conexгo estгo corretas, como no link que eu mandei.

Olha o exemplo na wiki (adaptado):

Код:
new MySQL:Conexao;
// ...
public OnGameModeInit()
{
	Conexao = mysql_connect("127.0.0.1", "root", "mypass", "mydatabase"); // Conecta а database com base nas informaзхes digitadas.

	if(mysql_errno(Conexao) != 0)  print("Erro ao se conectar а base de dados.!"); // Verifica se a conexгo й vбlida, ou seja, sem erros.
	return 1;
}