WTF IS THIS MYSQL INI
#1

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

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

I love you (no homo)...
Thanks for the link for fletch... but this query again returns This User Must Login
Reply
#4

Show current code. Did you remember to use mysql_store_result?
Reply
#5

Thanks again. Can i pm you if i have more errors ?
Reply
#6

Keep posting in this board, there is a lot of other people who want to help too.
Reply
#7

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)