MYSQL Query doesn't load all rows -
Biesmen - 29.04.2011
I have a problem with my MYSQL query. The query doesn't load all the rows stated below. The rows are named correctly, everything is correct.
code:
pawn Код:
format(query, sizeof(query), "SELECT `kills`,`deaths`,`points`,`infpoints` FROM `users` WHERE `username` = '%s'", PlayerName(playerid));
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row_format(query))
{
sscanf(query, "p<|>iiii", Kills[playerid], Deaths[playerid], Points[playerid], FPoints[playerid]);
printf("Selected %d rows", mysql_num_rows());
} else {
print("Nothing found");
}
It loads only one row, and I think that row is called "kills".
I hope you can help me.
Re: MYSQL Query doesn't load all rows -
JaTochNietDan - 29.04.2011
What does it print out exactly? Also your sscanf doesn't make sense, what are you splitting the string by? Spaces by defualt I guess, but that's not how the mysql_fetch_row_format function formats the string by default, it formats it splitting everything up with | characters, so your sscanf should be the following:
pawn Код:
sscanf(query, "p<|>iiii", Kills[playerid], Deaths[playerid], Points[playerid], FPoints[playerid]);
That is assuming you're using the plugin version, if that does not fix it then you should add a print of the "query" variable to see how it is formatted.
Re: MYSQL Query doesn't load all rows -
Biesmen - 29.04.2011
Eh, I do not see a difference between your SSCANF line and mine.
And, this is what it prints:
Edit:
I retyped the whole code in this forum, I didn't copy or paste it. It seems like I made a typo in my script. The code here on the forum is the correct code.
Conclusion:
Fixed
Thanks for helping.
Re: MYSQL Query doesn't load all rows -
JaTochNietDan - 29.04.2011
Quote:
Originally Posted by Biesmen
Eh, I do not see a difference between your SSCANF line and mine.
And, this is what it prints:
|
Well actually you edited it, because when you originally posted it, you didn't have the split character specified in it.
Also what's wrong with the print? And like I said, print out your query variable so we can see the format of the query variable.
Re: MYSQL Query doesn't load all rows -
Biesmen - 29.04.2011
Quote:
Originally Posted by JaTochNietDan
Well actually you edited it, because when you originally posted it, you didn't have the split character specified in it.
|
Yeah, I edited it one minute after I posted it.
You're fast.
Anyway, read my post above (the edited version).
Thanks
And there's something wrong with my print or something, it still says it selected one row.