17.09.2010, 02:02
Hi there,
I am having trouble with inserting floats into my MySQL database.
In my database, my table has 3 fields called EntX, EntY, EntZ. Their types are all floats, and they don't have a length.
This is my code:
And this is what I get when I query it into the database.
This is my MySQL Log.
Sigh,
Can anyone help please.
I am having trouble with inserting floats into my MySQL database.
In my database, my table has 3 fields called EntX, EntY, EntZ. Their types are all floats, and they don't have a length.
This is my code:
pawn Код:
CreateBusiness(1, "A Test", 20000, 0.0000, 0.0000, 4.0000); // Create Bizz.
//The Actual function.
function CreateBusiness(bid, Bizzname[], price, Float:EnterX, Float:EnterY, Float:EnterZ)
{
if(bid > MAX_HOUSES) return 0;
format(str, sizeof(str), "SELECT * FROM `bizzinfo` WHERE `bid` = %d", bid);
mysql_query(str);
mysql_store_result();
if(mysql_num_rows() > 0) return 0;
format(str, sizeof(str), "INSERT INTO `bizzinfo` (bid, BizzName, Owner, Price, PayAmount, EntX, EntY, EntZ) VALUES (%d, '%s', 'For Sale', %d, 5000, %f, %f, %f)", bid, Bizzname, price, EnterX, EnterY, EnterZ);
mysql_query(str);
printf("[BIZZ]: Business ID: %d was added to the database.", bid);
mysql_free_result();
return 1;
}
This is my MySQL Log.
Код:
[Thu Sep 16 21:06:16 2010] ------------------------- [Thu Sep 16 21:06:16 2010] Logging Started [Thu Sep 16 21:06:16 2010] ------------------------- [Thu Sep 16 21:06:16 2010] Connected (0) to root @ localhost via TCP/IP. [Thu Sep 16 21:06:16 2010] MySQL Version 5.1.36-community-log. [Thu Sep 16 21:06:16 2010] Function: mysql_query executed: "SELECT * FROM `bizzinfo` WHERE `bid` = 1" with result: "0". [Thu Sep 16 21:06:16 2010] Function: mysql_store_result executed with result: "1" [Thu Sep 16 21:06:16 2010] Function: mysql_num_rows executed with result: "". [Thu Sep 16 21:06:16 2010] Function: mysql_query executed: "INSERT INTO `bizzinfo` (bid, BizzName, Owner, Price, PayAmount, EntX, EntY, EntZ) VALUES (1, 'A Test', 'For Sale', 20000, 5000, 0.000000, 0.000000, 4.000000)" with result: "0". [Thu Sep 16 21:06:16 2010] Function: mysql_free_result executed. [Thu Sep 16 21:06:16 2010] Function: mysql_query executed: "SELECT * FROM `bizzinfo`" with result: "0". [Thu Sep 16 21:06:16 2010] Function: mysql_store_result executed with result: "1" [Thu Sep 16 21:06:16 2010] Function: mysql_num_rows executed with result: "". [Thu Sep 16 21:06:16 2010] Function: mysql_fetch_row executed with result: "1|A Test|For Sale|20000|5000|0|0|4". [Thu Sep 16 21:06:16 2010] Function: mysql_free_result executed.
Can anyone help please.