query loads always same row
#1

pawn Код:
forward LoadPlayerKeys();
public LoadPlayerKeys()
{

    for(new i; i < MAX_PLAYER_VEHICLES; i++)
    {
        new query[100];
        new var[25] = "Mark";
        format(query, sizeof(query),"SELECT * FROM vehicles  WHERE owner='%s'",var);
        mysql_query(query);

        mysql_store_result();

        if(mysql_num_rows())
        if(mysql_fetch_row(query,"|"))
        {
            sscanf(query, "p<|>e<i>",playerkeys[i]);
            printf("keys loaded %d",playerkeys[i]);
            printf("%s",query);
        }
    }
}
What is wrong with this code? The query is always the same let me show you the output!

Quote:

[14:12:24] keys loaded 1
[14:12:24] 1|555|1|1|0|0|0|0|Mark|0|0|0
[14:12:24] keys loaded 1
[14:12:24] 1|555|1|1|0|0|0|0|Mark|0|0|0
[14:12:24] keys loaded 1
[14:12:24] 1|555|1|1|0|0|0|0|Mark|0|0|0
[14:12:24] keys loaded 1
[14:12:24] 1|555|1|1|0|0|0|0|Mark|0|0|0
[14:12:24] keys loaded 1
[14:12:24] 1|555|1|1|0|0|0|0|Mark|0|0|0

Reply
#2

Did you even read the code?

You're always loading Mark's keys.
Reply
#3

How can i solve it? I need to load 5 ids to the variable playerkeys.
Reply
#4

If there are vehicle IDs in the database, check for the ID according to the looping index variable, which in this case is i.
Reply
#5

I think the mysql plugin its buged.
Reply
#6

Bump 24 hours after. I need help with this!
Reply
#7

pawn Код:
for(new i; i < MAX_PLAYER_VEHICLES; i++)
    {
        new query[100];
        new var[25] = "Mark";
        format(query, sizeof(query),"SELECT * FROM vehicles  WHERE owner='%s'",var);
        mysql_query(query);
In your code, you are looping through all Vehicles, [i], and in your format, your %s is defines as "Mark" ("var")..

That makes it only show the same all the time. Modify it and make it load what you want it to load.
Reply
#8

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
In your code, you are looping through all Vehicles, [i], and in your format, your %s is defines as "Mark" ("var")..

That makes it only show the same all the time. Modify it and make it load what you want it to load.
Im looping through all player vehicles that are five and i want to load the vehicles id's from the database to the variable playerkeys.

Can you correct the code ? Thank's in advance!
Reply
#9

Sorry, not familiar with MySQL.. :/
Reply
#10

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
Sorry, not familiar with MySQL.. :/
I hope someone else does!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)