SA-MP Forums Archive
MYSQL String Problem - 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 String Problem (/showthread.php?tid=527447)



MYSQL String Problem - Cole_William - 22.07.2014

I've been trying multiple ways to make it so that it will insert the players name into the account area, at the same time i have no idea if it's a hashing error?

pawn Код:
new string[310], HashedPW[145];
    WP_Hash(HashedPW, sizeof (HashedPW), inputtext);
    format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetPlayerName(playerid), HashedPW);
    mysql_query(string);

Error:
Код:
warning 202: number of arguments does not match definition



Re: MYSQL String Problem - Sawalha - 22.07.2014

Which line warning show?


Re: MYSQL String Problem - Cole_William - 22.07.2014

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
Which line warning show?
The
pawn Код:
format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetPlayerName(playerid), HashedPW);



Re: MYSQL String Problem - nmader - 22.07.2014

Actually, if you are using an updated version of mysql (BlueG's at least) you have to use:
pawn Код:
mysql_query(DB, string);
When you start your connection you do DB = blablabla
pawn Код:
DB = mysql_connect(conntectshit);



Re: MYSQL String Problem - arlindi - 22.07.2014

PHP код:
new string[310], HashedPW[145];
    
WP_Hash(HashedPWsizeof (HashedPW), inputtext);
format(stringsizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')"GetPlayerName(playerid), HashedPW);
    
mysql_query(string); 



Re: MYSQL String Problem - Sawalha - 22.07.2014

That's the problem, solve:
pawn Код:
new name[MAX_PLAYER_NAME];
format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetPlayerName(playerid, name, sizeof(name)), HashedPW);
Wrong GetPlayerName format..
You forgot the size of variable (name) and sizeof it


Re: MYSQL String Problem - Cole_William - 22.07.2014

Quote:
Originally Posted by arlindi
Посмотреть сообщение
PHP код:
new string[310], HashedPW[145];
    
WP_Hash(HashedPWsizeof (HashedPW), inputtext);
format(stringsizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')"GetPlayerName(playerid), HashedPW);
    
mysql_query(string); 
You just copy / pasted the exact code that was there....


Re: MYSQL String Problem - Cole_William - 22.07.2014

Quote:
Originally Posted by Sawalha
Посмотреть сообщение
That's the problem, solve:
pawn Код:
new name[MAX_PLAYER_NAME];
format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetPlayerName(playerid, name, sizeof(name)), HashedPW);
Wrong GetPlayerName format..
You forgot the size of variable (name) and sizeof it
Why did it work like that? Cause name is defined in the stock GetName

pawn Код:
stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}



Re: MYSQL String Problem - Cole_William - 22.07.2014

Quote:
Originally Posted by nmader
Посмотреть сообщение
Actually, if you are using an updated version of mysql (BlueG's at least) you have to use:
pawn Код:
mysql_query(DB, string);
When you start your connection you do DB = blablabla
pawn Код:
DB = mysql_connect(conntectshit);
I updated to R7 and now it's saying

Код:
warning 204: symbol is assigned a value that is never used: "DB"
error 017: undefined symbol "mysql_query"
error 017: undefined symbol "mysql_query"
error 017: undefined symbol "mysql_query"
pawn Код:
DB = mysql_connect("localhost","user","db","pass"); // Gamemodeinit
pawn Код:
new string[310], HashedPW[145];
    WP_Hash(HashedPW, sizeof (HashedPW), inputtext);
    format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetName(playerid), HashedPW);
    mysql_query(DB, string);



Re: MYSQL String Problem - driftpower - 22.07.2014

Quote:
Originally Posted by Cole_William
Посмотреть сообщение
I updated to R7 and now it's saying

Код:
warning 204: symbol is assigned a value that is never used: "DB"
error 017: undefined symbol "mysql_query"
error 017: undefined symbol "mysql_query"
error 017: undefined symbol "mysql_query"
pawn Код:
DB = mysql_connect("localhost","user","db","pass"); // Gamemodeinit
pawn Код:
new string[310], HashedPW[145];
    WP_Hash(HashedPW, sizeof (HashedPW), inputtext);
    format(string, sizeof(string), "INSERT INTO `accounts` (Name, Password) VALUES ('%s', '%s')", GetName(playerid), HashedPW);
    mysql_query(DB, string);
Looks like wrong include!