SA-MP Forums Archive
MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL (/showthread.php?tid=613773)



MySQL - Sirop - 31.07.2016

Hi everybody,
sorry for my English
That's when I connect to the server nothing happens no dialog nothing

Код HTML:
public OnPlayerConnect(playerid)
{
    AntiDeAMX();
	Logged[playerid] = false;

    new query[128]; //We use this variable to format our query
	GetPlayerName(playerid, nsql[playerid], 24); //Getting player's name
	GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
	mysql_format(mysql, query, sizeof(query),"SELECT `Pass`, `ID` FROM `utilisateur` WHERE `Nom` = '%e' LIMIT 1", nsql[playerid]);
	mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    return 1;
}
Код HTML:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
	new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
	cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
	if(rows) //if there is row
	{//then
		cache_get_field_content(0, "Pass", pInfo[playerid][Pass], mysql, 129);
		pInfo[playerid][pID] = cache_get_field_content_int(0, "ID"); 
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Connexion", "connnecte toi fdp !!!", "Connexion", "Quitter");
	}
	else 
	{
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "inscription", "inscrie toi enkuler de ton pere", "inscrire", "partir");
	}
	return 1;
}
Код HTML:
-- --------------------------------------------------------

--
-- Structure de la table `utilisateur`
--

CREATE TABLE IF NOT EXISTS `utilisateur` (
  `ID` int(10) NOT NULL,
  `Nom` varchar(24) NOT NULL,
  `Pass` varchar(129) NOT NULL,
  `Admin` int(10) NOT NULL,
  `IP` varchar(10) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Re: MySQL - Shinja - 31.07.2016

You sure your mysql connects fine?
you should have a line mysql = mysql_connect(...);


Re: MySQL - Sirop - 31.07.2016

Yes when I run server.exe the database connects to the server

I have in OnGameMode

SQL_connecte


Re: MySQL - Shinja - 31.07.2016

then replace "mysql" with "SQL_connecte" in your code
Not in functions take care lol


Re: MySQL - Shinja - 31.07.2016

PHP код:
mysql_format(SQL_connectequerysizeof(query),"SELECT `Pass`, `ID` FROM `utilisateur` WHERE `Nom` = '%e' LIMIT 1"nsql[playerid]);
    
mysql_tquery(SQL_connectequery"OnAccountCheck""i"playerid); 
PHP код:
ache_get_data(rowsfields);//let's get the rows and fields from the database.
    
if(rows//if there is row
    
{//then
        
cache_get_field_content(0"Pass"pInfo[playerid][Pass]);
        
pInfo[playerid][pID] = cache_get_field_content_int(0"ID"); 
    } 



Re: MySQL - Sirop - 31.07.2016

C:\Users\Yamaha\Desktop\Serveur Secondair RP\gamemodes\sdrp.pwn(4484) : error 076: syntax error in the expression, or invalid function call
C:\Users\Yamaha\Desktop\Serveur Secondair RP\gamemodes\sdrp.pwn(4485) : error 076: syntax error in the expression, or invalid function call

mysql_format(SQL_connecte, query, sizeof(query),"SELECT `Pass`, `ID` FROM `utilisateur` WHERE `Nom` = '%e' LIMIT 1", nsql[playerid]);
mysql_tquery(SQL_connecte, query, "OnAccountCheck", "i", playerid);


Re: MySQL - Konstantinos - 31.07.2016

Reverse back to the initial code. SQL_connecte is a function that is called in OnGameModeInit, isn't it? Can you also post mysql log?


Re: MySQL - Sirop - 31.07.2016

In OnGameMode

SQL_Connecte();

And the fonction

SQL_Connecte() {
g_iHandle = mysql_connecte(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD);

if (mysql_errno(g_iHandle) != 0) {
printf("[SQL] Connexion a \"%s\" avec la base de donnйe \"%s\" ratй ! vйrifier les paramиtres de connexion...\a", SQL_HOSTNAME, SQL_DATABASE);
}
else {
printf("[SQL] Connexion a \"%s\" avec la base de donnйe \"%s\" reussi !", SQL_HOSTNAME, SQL_DATABASE);
}
}


And

[SQL] Connexion a "127.0.0.1" avec la base de donnйe "rp-l" reussi ! = successful

is in serveur log


Re: MySQL - Konstantinos - 31.07.2016

You store the connection handle to "g_iHandle" but you use "mysql" in mysql functions. Do you get any warning or error in mysql log such as "invalid connection handle" or have multiple connections?


Re: MySQL - Shinja - 31.07.2016

g_iHandle is your connect so, not SQL_connecte

Here is the new code

PHP код:
mysql_format(g_iHandequerysizeof(query),"SELECT `Pass`, `ID` FROM `utilisateur` WHERE `Nom` = '%e' LIMIT 1"nsql[playerid]);
    
mysql_tquery(g_iHandlequery"OnAccountCheck""i"playerid); 
PHP код:
ache_get_data(rowsfields);//let's get the rows and fields from the database.
    
if(rows//if there is row
    
{//then
        
cache_get_field_content(0"Pass"pInfo[playerid][Pass]);
        
pInfo[playerid][pID] = cache_get_field_content_int(0"ID"); 
    }