MySQL Data Issue
#1

On my database, I have the following information:

pawn Код:
ID  Name    Type    FBank
1   Los Angeles Police  0   0
2   Fire Department 3   5


And on the server/server process, it shows:

pawn Код:
[23:16:44]  Faction : Los Angeles Police  Faction Type : 111  Faction Bank : 115
[23:16:44]  Faction : Fire Department  Faction Type : 105  Faction Bank : 114
The code is:

pawn Код:
if(mysql_fetch_row_format(Query,"|"))
        {
            sscanf(Query, "p<|>e<is[30]dd>", FactionInfo[id]);
            printf(" Faction : %s  Faction Type : %d  Faction Bank : %d", FactionInfo[id][Name],FactionInfo[id][Type],FactionInfo[id][FBank]);
        }

How can I fix this, thank you in advance.
Reply
#2

Put this in OnGameModeInit (or fs init)
pawn Код:
mysql_debug(1);
Run your mode, then look at the debug file it creates (debug.txt in server root directory). See what values the database is returning. If its returning the correct values the sscanf line will be the culprit. I have never used sscanf with enums like that so i don't know if its valid or not. Posting the enum may help too.
Reply
#3

Enum:

pawn Код:
enum finfo
{
    ID,
    Name[30],
    Type,
    FBank
};
And debug:
pawn Код:
[00:14:49] CMySQLHandler::Query(SELECT * FROM Factions WHERE ID= 1) - Successfully executed.

[00:14:49] >> mysql_store_result( Connection handle: 1 )

[00:14:49] CMySQLHandler::StoreResult() - Result was stored.

[00:14:49] >> mysql_num_rows( Connection handle: 1 )

[00:14:49] CMySQLHandler::NumRows() - Returned 1 row(s)

[00:14:49] >> mysql_fetch_row_format( Connection handle: 1 )

[00:14:49] CMySQLHandler::FetchRow() - Return: 1|Los Angeles Police|1|500000

[00:14:49] >> mysql_query( Connection handle: 1 )

[00:14:49] CMySQLHandler::Query(SELECT * FROM Factions WHERE ID= 2) - Successfully executed.

[00:14:49] >> mysql_store_result( Connection handle: 1 )

[00:14:49] CMySQLHandler::StoreResult() - Result was stored.

[00:14:49] >> mysql_num_rows( Connection handle: 1 )

[00:14:49] CMySQLHandler::NumRows() - Returned 1 row(s)

[00:14:49] >> mysql_fetch_row_format( Connection handle: 1 )

[00:14:49] CMySQLHandler::FetchRow() - Return: 2|Fire Department|3|5
Reply
#4

Try this,

pawn Код:
sscanf(Query, "p<|>is[30]dd", FactionInfo[id][ID],FactionInfo[id][Name], FactionInfo[id][Type], FactionInfo[id][FBank]);
If that works, something is wrong either with your syntax or sscanf. Maybe post in sscanf thread for better help from ******.

EDIT: Since you select all in your query i don't know what order to put the variables in the sscanf line i posted, you will need to do that yourself.

EDIT2: fixed
Reply
#5

With your edit, it now displays this:

pawn Код:
[08:03:24]  Faction : L  Angeles Police  Faction Type : 1  Faction Bank : 500000
[08:03:24]  Faction : Fe Department  Faction Type : 3  Faction Bank :
Reply
#6

Anyone Know why it's displaying Parts of the name now? Help is appreciated fully.
Reply
#7

Bump. No one sees post on the second page :/
Reply
#8

Delete this comment, was suppose to make topic not post :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)