SA-MP Forums Archive
[MySQL] Unloading information from database - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [MySQL] Unloading information from database (/showthread.php?tid=151956)



[MySQL] Unloading information from database - Agent Smith - 01.06.2010

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.


Re: [MySQL] Unloading information from database - Agent Smith - 02.06.2010

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


Re: [MySQL] Unloading information from database - WackoX - 02.06.2010

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


Re: [MySQL] Unloading information from database - Agent Smith - 02.06.2010

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



Re: [MySQL] Unloading information from database - woot - 02.06.2010

That's what you did ..

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



Re: [MySQL] Unloading information from database - Agent Smith - 02.06.2010

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



Re: [MySQL] Unloading information from database - Agent Smith - 02.06.2010

*Bump* Anyone?


Re: [MySQL] Unloading information from database - Agent Smith - 03.06.2010

BUMP?


Re: [MySQL] Unloading information from database - mevi - 03.06.2010

Wow your pro with dubble posting.


Re: [MySQL] Unloading information from database - WackoX - 03.06.2010

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