PDA

View Full Version : Problem with loading string from MySQL (R8)


kristo
22/03/2013, 12:12 PM
Everything is loading fine but the business name.

Code:

forward LaeFirmad();
public LaeFirmad()
{
new rows, fields, string[128];
cache_get_data(rows, fields);
for (new i; i < rows; i++)
{
FirmaInfo[i][fID] = cache_get_field_int(i, "ID");
cache_get_field_content(i, "nimi", FirmaInfo[i][fNimi]); // Problem should be here
FirmaInfo[i][fOut][0] = cache_get_field_float(i, "outX");
FirmaInfo[i][fOut][1] = cache_get_field_float(i, "outY");
FirmaInfo[i][fOut][2] = cache_get_field_float(i, "outZ");
FirmaInfo[i][fIn][0] = cache_get_field_float(i, "inX");
FirmaInfo[i][fIn][1] = cache_get_field_float(i, "inY");
FirmaInfo[i][fIn][2] = cache_get_field_float(i, "inZ");
FirmaInfo[i][fRob][0] = cache_get_field_float(i, "robX");
FirmaInfo[i][fRob][1] = cache_get_field_float(i, "robY");
FirmaInfo[i][fRob][2] = cache_get_field_float(i, "robZ");
printf("%i | %s | %f | %f | %f", FirmaInfo[i][fID], FirmaInfo[i][fNimi],
FirmaInfo[i][fOut][0], FirmaInfo[i][fOut][1], FirmaInfo[i][fOut][2]);
if (FirmaInfo[i][fOut][0] != 0.0)
{
CreateDynamicPickup(1239, 1, FirmaInfo[i][fOut][0], FirmaInfo[i][fOut][1], FirmaInfo[i][fOut][2]);
CreateDynamicPickup(1239, 1, FirmaInfo[i][fIn][0], FirmaInfo[i][fIn][1], FirmaInfo[i][fIn][2]);
CreateDynamicPickup(1239, 1, FirmaInfo[i][fRob][0], FirmaInfo[i][fRob][1], FirmaInfo[i][fRob][2]);
format(string, sizeof(string), "Firma: %s", FirmaInfo[i][fNimi]);
CreateDynamic3DTextLabel(string, COLOR_YELLOW, FirmaInfo[i][fOut][0], FirmaInfo[i][fOut][1], FirmaInfo[i][fOut][2], 20);
CreateDynamic3DTextLabel("/röövi", COLOR_RED, FirmaInfo[i][fRob][0], FirmaInfo[i][fRob][1], FirmaInfo[i][fRob][2], 20);
}
}
printf("Laeti %i firmat.", rows);
}



Debug line:

printf("%i | %s | %f | %f | %f", FirmaInfo[i][fID], FirmaInfo[i][fNimi],
FirmaInfo[i][fOut][0], FirmaInfo[i][fOut][1], FirmaInfo[i][fOut][2]);

Shows this:

[14:06:31] 1 | | 1524.430053 | -1678.319946 | 13.231599

Anyone has good eyes and sees the mistake?

InfiniTy.
22/03/2013, 12:30 PM
Well i had the same problem but with cache_get_row. All i did is format it and it worked.
For example :

cache_get_row(TotalBusinesses, 1, temp), format(BizzData[TotalBusinesses][bOwner],sizeof(temp),temp);


cache_get_field_content(i, "nimi", string); // Problem should be here
format(FirmaInfo[i][fNimi],sizeof(string),string);

Should probably work..not sure tho.

@PaulDinam - oh.. so you are a wizard .. you know that dbHandle is his variable to store the connection and that 1 is the field id for the name of the 'firma' .. oh cool.Can you teach me sometime soon ?:)

PaulDinam
22/03/2013, 12:32 PM
Here is a good one:

cache_get_row(i, 1, FirmaInfo[i][fNimi], dbHandle, 128 );

kristo
22/03/2013, 12:45 PM
Adytza., thank you :)

[15:09:04] 1 | Test | 1524.430053 | -1678.319946 | 13.231599