03.02.2010, 22:10
Thanks for the mysql_fetch_field catch and the idea, I've fixed mysql_fetch_field, and added mysql_fetch_row_data, which will be able to work with mysql_fetch_field. I want to test it a little more, I'll be uploading it soon.
EDIT:
Updated.
[anchor=mysql_fetch_row_data]_________________________________________________
How to use mysql_fetch_row_data
Example usage:
(Although I suggest you to use mysql_fetch_row with split or sscanf)
Here is an example of loading all the houses from a table:
Here is an example on loading a players info for login:
EDIT:
Updated.
[anchor=mysql_fetch_row_data]_________________________________________________
How to use mysql_fetch_row_data
Example usage:
(Although I suggest you to use mysql_fetch_row with split or sscanf)
Here is an example of loading all the houses from a table:
Code:
mysql_query("SELECT * FROM `houses`"); mysql_store_result(); new buffer[64]; new int i = 0; while(mysql_fetch_row_data()) { mysql_fetch_field("X", buffer); // Here you would set the house X coord to: floatstr(buffer); mysql_fetch_field("Y", buffer); // Here you would set the house Y coord to: floatstr(buffer); mysql_fetch_field("Z", buffer); // Here you would set the house Z coord to: floatstr(buffer); mysql_fetch_field("owner", buffer); // Here you would set the house owner to: strval(buffer); mysql_fetch_field("price", buffer); // Here you would set the house price to: strval(buffer); i++; } printf("%d total houses loaded.", i); mysql_free_result();
Code:
mysql_query("SELECT * FROM `accounts` where `name` = 'PLAYERNAME'"); mysql_store_result(); new buffer[64]; if(mysql_fetch_row_data()) { mysql_fetch_field("money", buffer); // Here you would set the players money to: strval(buffer); mysql_fetch_field("kills", buffer); // Here you would set the players kills to: strval(buffer); mysql_fetch_field("deaths", buffer); // Here you would set the players deaths to: strval(buffer); // Set variable that the player is logged in. mysql_free_result(); } else { // No rows could be fetched thus the account does not exist. }