Getting a string from MySQL
#1

How can I do this? I want to get the Owner field for my house system because it isn't saving to the "hOwner" variable.

pawn Код:
HouseInfo[houses][hID] = data[0];
        HouseInfo[houses][hX] = fdata[0];
        HouseInfo[houses][hY] = fdata[1];
        HouseInfo[houses][hZ] = fdata[2];
        HouseInfo[houses][hPrice] = data[1];
        HouseInfo[houses][hOwner] = Owner[21];
        HouseInfo[houses][hOwned] = data[2];
        HouseInfo[houses][hIntX] = fdata[3];
        HouseInfo[houses][hIntY] = fdata[4];
        HouseInfo[houses][hIntZ] = fdata[5];
        HouseInfo[houses][hInt] = data[3];
        printf("Owners: %s", HouseInfo[houses][hOwner]);
What should I use?
Reply
#2

I know i'm doing wrong by bumping when it's only on the first page but I need this fixing. Thanks.
Reply
#3

Please, I really need this fixed by tomorrow!
Reply
#4

Try showing the query? ¬_¬
Reply
#5

Query is a simple:
pawn Код:
mysql_query("SELECT * FROM `houses`");
Reply
#6

I have a simple house loading system, here is an adapted version with basic somments.

Код:
new query[300], rowstring[60];
mysql_query("SELECT * FROM `houses`");

new queryresult[300]; //This is the string we will use to store the data in, before we process it
mysql_store_result();

if(mysql_num_rows() > 0) { //If there are any rows then....
	while(mysql_fetch_row_format(queryresult, "|")) { //For each row of data
		mysql_fetch_field_row(queryresult, "FEILDNAME"); //Puts the string representation of 'FEILDNAME' into queryresult
		//Do somthing with the data

		mysql_fetch_field_row(queryresult, "FEILDINT"); //Puts the string representation of 'FEILDINT' into queryresult
		new AsInt = int:strval(queryresult);

		mysql_fetch_field_row(queryresult, "FEILDFLOAT"); //Puts the string representation of 'FEILDFLOAT' into queryresult
		new AsFloat = floatstr(queryresult);
	}
}

mysql_free_result(); // Free the results
Reply
#7

Use format for string:

pawn Код:
format(HouseInfo[houses][hOwner],sizeof(HouseInfo[houses][hOwner]),"%s",Owner[21]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)