SA-MP Forums Archive
MySQL syntax help - 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 syntax help (/showthread.php?tid=657754)



MySQL syntax help - Heress - 15.08.2018

Код:
public OnPlayerConnect(playerid)
{
    new vardas [MAX_PLAYER_NAME], query[64];
    GetPlayerName(playerid, vardas, sizeof(vardas));
    format(query, sizeof(query), "SELECT `id` FROM `user` WHERE `vardas` = '%s'", vardas);
    mysql_function_query(manomysql, query, true, "OnUserCheck", "i", playerid);
    return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOG_REGISTER)
	{
		if(response)
		{
		    //Slaptaћodћio ilgis
	        new Vardas[MAX_PLAYER_NAME], query[64], slaptazodis[32];
	        GetPlayerName(playerid, Vardas, sizeof(Vardas));
	        if(strlen(inputtext) >= 6)
	        {
	            mysql_escape_string(inputtext, slaptazodis, manomysql);
	            format(query, sizeof(query), "INSERT INTO `user` (`vardas`, `slaptazodis`) VALUES ('%s', '%s')", Vardas, inputtext);
	            mysql_function_query(manomysql, query, false, " ", " ");
	            SendClientMessage(playerid, LIME, "Sėkmingai uћsiregistravote serveryje! Gero ћaidimo");
	        }
	        else
	        {
	            SendClientMessage(playerid, MELYNA, "Slaptaћodis turi būti bent 6 simbolių ilgio!");
	            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registracija", "Praљome įvesti sugalvotą slaptaћodį!", "Registruotis", "Iљeiti");
	        }
	    }
	    else
	    {
	        Kick(playerid);
	        SendClientMessage(playerid, RAUDONA, "Atљaukėte registraciją!");
	    }
	}
Error:
Quote:

[14:17:36] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

How to fix it?


Nobody help me in old thread... So I create new...


Re: MySQL syntax help - Heress - 15.08.2018

Any ideas?


Re: MySQL syntax help - Florin48 - 15.08.2018

use mysql_tquery instead of mysql_function_query, and the latest version of mysql, or r39+


Re: MySQL syntax help - Heress - 17.08.2018

Quote:

C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(34) : warning 213: tag mismatch
C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(40) : warning 213: tag mismatch
C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(55) : error 017: undefined symbol "cache_get_data"
C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(54) : warning 203: symbol is never used: "num_fields"
C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(73) : error 017: undefined symbol "mysql_fumction_query"
C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(25 : error 017: undefined symbol "mysql_function_query"

Quote:

34. manomysql = mysql_connect(db_host, db_user, db_db, db_pass);
40. mysql_close(manomysql);
55. cache_get_data(num_rows, num_fields, manomysql);
54. new num_rows, num_fields;
73. mysql_fumction_query(manomysql, query, true, "OnUserCheck", "i", playerid);
258. mysql_function_query(manomysql, query, false, "", "");

More script in first post..


Re: MySQL syntax help - Akeem - 17.08.2018

I think the code your using is outdated try using pquery


Re: MySQL syntax help - Heress - 18.08.2018

I changed mysql_function_query to mysql_pquery

line(74):
Quote:

mysql_pquery(manomysql, query, "OnUserCheck", "i", playerid);

error:
Quote:

C:\Users\Nerijus\Desktop\Socotra.lt\gamemodes\garz a.pwn(74) : warning 213: tag mismatch




Re: MySQL syntax help - KinderClans - 18.08.2018

pawn Код:
new query[103];
    mysql_format(manomysql, query, sizeof query, "SELECT `id` FROM `user` WHERE `vardas` = '%e' LIMIT 1", vardas);
    mysql_tquery(manomysql, query, "OnUserCheck", "dd", playerid);
Also i suggest you to upgrade to latest mysql plugin version.


Re: MySQL syntax help - Heress - 18.08.2018

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
pawn Код:
new query[103];
    mysql_format(manomysql, query, sizeof query, "SELECT `id` FROM `user` WHERE `vardas` = '%e' LIMIT 1", vardas);
    mysql_tquery(manomysql, query, "OnUserCheck", "dd", playerid);
Also i suggest you to upgrade to latest mysql plugin version.
I downloaded r41-3 mysql plugin. Updated files in plugins and includes. Where I have to paste libmariadb.dll and log-core.dll ?


Re: MySQL syntax help - Calisthenics - 18.08.2018

The size of the query variable is 64 but the INSERT query is 60 characters itself without filling in the name and password.

Another crucial thing to mention: STOP saving passwords as plain text - hash them!


Re: MySQL syntax help - KinderClans - 18.08.2018

Quote:
Originally Posted by Heress
Посмотреть сообщение
I downloaded r41-3 mysql plugin. Updated files in plugins and includes. Where I have to paste libmariadb.dll and log-core.dll ?
In your samp server folder. Also latest is R41-4.

And as @Calisthenics said, HASH your passwords! Use SHA-256 and salt.

I suggest you to rewrote your user system and replace it with this.