Getting a string from MySQL - 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)
+--- Thread: Getting a string from MySQL (
/showthread.php?tid=323479)
Getting a string from MySQL -
Luis- - 05.03.2012
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?
Re: Getting a string from MySQL -
Luis- - 05.03.2012
I know i'm doing wrong by bumping when it's only on the first page but I need this fixing. Thanks.
Re: Getting a string from MySQL -
Luis- - 06.03.2012
Please, I really need this fixed by tomorrow!
Re: Getting a string from MySQL -
MP2 - 06.03.2012
Try showing the query? ¬_¬
Re: Getting a string from MySQL -
Luis- - 08.03.2012
Query is a simple:
pawn Код:
mysql_query("SELECT * FROM `houses`");
Re: Getting a string from MySQL -
Grimrandomer - 08.03.2012
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
Re: Getting a string from MySQL -
Shabi RoxX - 08.03.2012
Use format for string:
pawn Код:
format(HouseInfo[houses][hOwner],sizeof(HouseInfo[houses][hOwner]),"%s",Owner[21]);