WTF IS THIS MYSQL INI -
TheDeath - 27.07.2012
Hello i have really big problem with this f****n mysql INI
Код:
new Query[256],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,24);
format(Query,sizeof(Query),"SELECT * `users` WHERE username = %s LIMIT 1",pName);
mysql_query(Query);
if(mysql_num_rows() == 0){
print("This user must Register");
}else{
print("This user must login");
}
ROWS IN THIS TABLE:0
Returns This user must login!
2.Ok so lets imaginate i have made my registter/login system and i want to load the money of the player
How i can save it in some string ?!?!?!
Re: WTF IS THIS MYSQL INI -
Misiur - 27.07.2012
pawn Код:
format(Query,sizeof(Query),"SELECT * `users` WHERE username = %s LIMIT 1",pName);
//to
format(Query,sizeof(Query),"SELECT * FROM `users` WHERE username = '%s' LIMIT 1", pName);
Try to not use the * wildcard, just specify the field names.
2.
https://sampwiki.blast.hk/wiki/MySQL#mysql_fetch_field_row
Re: WTF IS THIS MYSQL INI -
TheDeath - 27.07.2012
I love you (no homo)...
Thanks for the link for fletch... but this query again returns This User Must Login
Re: WTF IS THIS MYSQL INI -
Misiur - 27.07.2012
Show current code. Did you remember to use mysql_store_result?
Re: WTF IS THIS MYSQL INI -
TheDeath - 27.07.2012
Thanks again. Can i pm you if i have more errors ?
Re: WTF IS THIS MYSQL INI -
Misiur - 27.07.2012
Keep posting in this board, there is a lot of other people who want to help too.
Re: WTF IS THIS MYSQL INI -
Vince - 27.07.2012
Slightly off-topic, but I find fetch_field_row a terrible way of loading data. This is fine if you don't know the field name, but most of the time you DO know the field name AND its index. Therefor, just using fetch_field with the index is much faster.
Re: WTF IS THIS MYSQL INI -
TheDeath - 27.07.2012
This doesnt insert nothing into mysql:
Код:
case DIALOG_REGISTER:
{
if(response){
if(strlen(inputtext) > 0)
{
new Query[256],pName[MAX_PLAYER_NAME],pass[32],PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,24);
mysql_real_escape_string(pName,PlayerName);
mysql_real_escape_string(inputtext,pass);
format(Query,sizeof(Query),"insert into users set Username='%s', Password='MD5('%s)', Admin='0'",PlayerName,pass);
mysql_query(Query);
}
else{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", "Please enter your password below to register!", "Register", "Exit");
}
}
else{
Kick(playerid);
}
}//END DIALOG_REGISTER
Can soeone tell me why ?
I have more fields but they have default valuve so it must be set to default!
And my primary key is username.
Re: WTF IS THIS MYSQL INI -
FireCat - 27.07.2012
Quote:
Originally Posted by Vince
Slightly off-topic, but I find fetch_field_row a terrible way of loading data. This is fine if you don't know the field name, but most of the time you DO know the field name AND its index. Therefor, just using fetch_field with the index is much faster.
|
No, with sscanf is better.
Store the result, format the row with a | and use sscanf to load it on an enum
Re: WTF IS THIS MYSQL INI -
Calgon - 27.07.2012
Quote:
Originally Posted by FireCat
No, with sscanf is better.
Store the result, format the row with a | and use sscanf to load it on an enum
|
No, it's not. You need to create a variable to dump all of the data in to, then use sscanf and it's just all extra overhead you don't need. At least with the MySQL fetch functions you can just dump the data in to the variables you want straight away.