[MySQL] Unloading information from database
#1

I didn't get any help in my previous topic so I thought I would make a new one but a little bit more detailed.

I get this problem when I'm trying to get Text information off a database. When I start up the server it is meant to say the name of the faction which has loaded but unforunatly it loads up a blank space:
Code:
[19:55:06] [Factions] Name: ID: 0
[19:55:06] [Factions] Name: ID: 1
[19:55:06] [Factions] Name: ID: 2
The IDs load up fine but the name doesn't. This is my loading code:
pawn Code:
public LoadFaction()
{
  new DataString[ 128 ], Query[ 128 ], idx;

    format( Query, sizeof( Query ), "SELECT * FROM factions");
    mysql_query( Query );
    mysql_store_result();

    while( mysql_fetch_row_data() )
    {
        mysql_fetch_field( "FactionID", DataString );
        DynamicFactions[ idx ][ FactionID ] = strval( DataString );

        mysql_fetch_field( "FactionName", DataString );
        DynamicFactions[ idx ][ FactionName ] = strval( DataString );

        printf("[Factions] Name: %s ID: %d",DynamicFactions[ idx ][ FactionName ],DynamicFactions[ idx ][ FactionID ]);

        idx++;
    }

    mysql_free_result();

    return 1;
}
(I've left some of the code out which wasn't needed)

On the MySQL database my table feild is:
Code:
varchar(68) 	latin1_swedish_ci
Does anyone know what I'm doing wrong? If you need more information just say and I'll explain it some more, thanks.
Reply
#2

*Bump*
Anyone? It would help fix a lot of my problems in the script
Reply
#3

Code:
DynamicFactions[ idx ][ FactionName ] = strval( DataString );
A name cannot be a decimal.
Reply
#4

There are no decimals in the text feild. Only:
Code:
San Ferrio Fire Department
Reply
#5

That's what you did ..

replace
pawn Code:
DynamicFactions[ idx ][ FactionName ] = strval( DataString );
with
pawn Code:
format(DynamicFactions[ idx ][ FactionName ], 128, "%s", DataString);
Reply
#6

Quote:
Originally Posted by //exora
That's what you did ..

replace
pawn Code:
DynamicFactions[ idx ][ FactionName ] = strval( DataString );
with
pawn Code:
format(DynamicFactions[ idx ][ FactionName ], 128, "%s", DataString);
Thanks for that It half works. Now the text loads but only the first letter:
Code:
[11:35:35] [Factions] Name: D
[11:35:35] [Factions] Name: L
[11:35:35] [Factions] Name: S
Reply
#7

*Bump* Anyone?
Reply
#8

BUMP?
Reply
#9

Wow your pro with dubble posting.
Reply
#10

FactionName is now a string, so after you created it put something like [128].
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)