SA-MP Forums Archive
query loads always same row - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: query loads always same row (/showthread.php?tid=411530)



query loads always same row - BlackRaven - 29.01.2013

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




Re: query loads always same row - ReneG - 29.01.2013

Did you even read the code?

You're always loading Mark's keys.


Re: query loads always same row - BlackRaven - 29.01.2013

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


Re: query loads always same row - SuperViper - 29.01.2013

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


Re: query loads always same row - BlackRaven - 29.01.2013

I think the mysql plugin its buged.


Re: query loads always same row - BlackRaven - 30.01.2013

Bump 24 hours after. I need help with this!


Re: query loads always same row - denNorske - 30.01.2013

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.


Re: query loads always same row - BlackRaven - 30.01.2013

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!


Re: query loads always same row - denNorske - 30.01.2013

Sorry, not familiar with MySQL.. :/


Re: query loads always same row - BlackRaven - 30.01.2013

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