SA-MP Forums Archive
SQL LoadBiz doens't works - 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: SQL LoadBiz doens't works (/showthread.php?tid=453863)



SQL LoadBiz doens't works - Sk1lleD - 26.07.2013

EDIT: I've solved on loading integer and float infos, but not on strings

Код:
public LoadBiz()
{
    new query[2048], DBResult: Result;
    Result = db_query(Database,"SELECT * FROM `bizs`");
    for(new a;a<db_num_rows(Result);a++)
    {
        db_get_field_assoc(Result,"owner",query,sizeof(query));
        format(BizInfo[a][bOwner], 30, query);
//other code here
}
}
The server will crash immediately on load


Re: SQL LoadBiz doens't works - TH3_R3D™ - 26.07.2013

Quote:
Originally Posted by Sk1lleD
Посмотреть сообщение
EDIT: I've solved on loading integer and float infos, but not on strings

Код:
public LoadBiz()
{
    new query[2048], DBResult: Result;
    Result = db_query(Database,"SELECT * FROM `bizs`");
    for(new a;a<db_num_rows(Result);a++)
    {
        db_get_field_assoc(Result,"owner",query,sizeof(query));
        format(BizInfo[a][bOwner], 30, query);
//other code here
}
}
The server will crash immediately on load
This loop is occurring this crash.

(I understand why you're looping)

but try:

pawn Код:
public LoadBiz()
{
    new query[2048], DBResult: Result;
    Result = db_query(Database,"SELECT * FROM `bizs`");
    if(db_num_rows(Result))
    {
        db_get_field_assoc(Result,"owner",query,sizeof(query));
        format(BizInfo[a][bOwner], 30, query);
//other code here
}
}



Re: SQL LoadBiz doens't works - Konstantinos - 26.07.2013

Quote:
Originally Posted by Sk1lleD
Посмотреть сообщение
The server will crash immediately on load
Are you really sure that the field is not null? Because if it is, it causes crashes.

By the way, you can just do:
pawn Код:
db_get_field_assoc(Result,"owner",BizInfo[a][bOwner],30);
Quote:
Originally Posted by TH3_R3D™
Посмотреть сообщение
but try:

pawn Код:
public LoadBiz()
{
    new query[2048], DBResult: Result;
    Result = db_query(Database,"SELECT * FROM `bizs`");
    if(db_num_rows(Result))
    {
        db_get_field_assoc(Result,"owner",query,sizeof(query));
        format(BizInfo[a][bOwner], 30, query);
//other code here
}
}
He does not have only 1 row, so he should use a loop.

@Sk1lleD Don't forget to use "db_next_row".


Re: SQL LoadBiz doens't works - Sk1lleD - 26.07.2013

@_Zeus
Thanks! +Rep.
And yes, there was db_next_row(Result);
EDIT: Solved the other problem too