MYSQL String Problem
#1

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
Reply
#2

Which line warning show?
Reply
#3

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);
Reply
#4

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);
Reply
#5

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); 
Reply
#6

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
Reply
#7

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....
Reply
#8

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;
}
Reply
#9

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);
Reply
#10

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!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)