mysql and sscanf
#1

If i use it like that it prints: "John Beer 0"

I want it to print: "Friend Nickname 1-10"
The field looks like:

Code:
Name:            FriendName:       RelationShip:
John Beer       Johny Beer                   2
Code:
    printf("%s", line);
    sscanf(line, "p<|>s[24]i", friendname, relation);
    printf("%s %d", friendname,  relation);
line string is perfectly printed but when it comes to string seperating it prints

Code:
 John Beer 0
JOHN BEER IS MY NICK, NOT MY FRIEND'S NICK!
Reply
#2

I didnt understand, you have trouble reading from mysql or what?
Reply
#3

maybe it's hard to understand, but you should read twice
Reply
#4

Show us the query
Reply
#5

Quote:
Originally Posted by exora
View Post
Show us the query
Code:
    format(string, sizeof(string), "SELECT * FROM `friends` WHERE `Name` = '%s'", GetUserName(playerid));
    mysql_query(string);
    mysql_store_result();
    mysql_fetch_row(line);
there should be nothing wrong here cause it prints John Beer|Johny Beer|2
Reply
#6

I may be missing something, but where in your query do you relate to the relationship level, and the friends name?
Reply
#7

Quote:
Originally Posted by Westie
View Post
I may be missing something, but where in your query do you relate to the relationship level, and the friends name?
i guess.. nowhere?
But with query there should be everything fine, explenation in previous post
Reply
#8

Your original posts explains appallingly your problem.

Try replacing playerid with the ID variable of your friend in the GetUserName function.
Reply
#9

You have to get all parameters.

pawn Code:
new nickname[24];
sscanf(line, "p<|>s[24]s[24]i", nickname, friendname, relation);
Reply
#10

Quote:
Originally Posted by MadeMan
View Post
You have to get all parameters.

pawn Code:
new nickname[24];
sscanf(line, "p<|>s[24]s[24]i", nickname, friendname, relation);
That wasn't that problem, i was missing something important in query!
Reply
#11

your sscanf needs to grab name before friendname.
pawn Код:
sscanf(line, "p<|>s[24]s[24]i", playername, friendname, relation);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)