SQL LoadBiz doens't works
#1

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
Reply
#2

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
}
}
Reply
#3

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".
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)