Mysql Insert errorr
#1

Having a little issue while trying to insert some data.

Code
pawn Код:
format(qq,sizeof(qq),"INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_Rot_Y,ATM_Rot_Z) VALUES ('1','5','%f','%f','%f','%f','%f','%f')",x,y,z,rx,ry,rz);
mysql_query(qq);
mysql_free_result();
Problem
pawn Код:
[10:33:11] >> mysql_query( Connection handle: 1 )

[10:33:11] CMySQLHandler::Query(SELECT * FROM `atm_data`) - Successfully executed.

[10:33:11] >> mysql_store_result( Connection handle: 1 )

[10:33:11] CMySQLHandler::StoreResult() - Result was stored.

[10:33:11] >> mysql_num_rows( Connection handle: 1 )

[10:33:11] CMySQLHandler::NumRows() - Returned 1 row(s)

[10:33:11] >> mysql_fetch_row_format( Connection handle: 1 )

[10:33:11] CMySQLHandler::FetchRow() - Return: 1|1|7|15.4374|1186.98|19.1082|0|0|90

[10:33:11] >> mysql_fetch_row_format( Connection handle: 1 )

[10:33:30] >> mysql_query( Connection handle: 1 )

[10:33:30] CMySQLHandler::Query(INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_Rot_Y,ATM_Rot_Z) VALUES ('1','5','19.256700','1191.1) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1191.1' at line 1)

[10:33:30] >> mysql_free_result( Connection handle: 1 )

[10:33:30] CMySQLHandler::FreeResult() - Result was successfully free'd.
Reply
#2

Make sure the array for qq is large enough.
Reply
#3

pawn Код:
printf("[DEBUG] Values: %f,%f,%f,%f,%f,%f",x,y,z,rx,ry,rz);
format(qq,sizeof(qq),"INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_Rot_Y,ATM_Rot_Z) VALUES ('1','5','%f','%f','%f','%f','%f','%f')",x,y,z,rx,ry,rz);
mysql_query(qq);
mysql_free_result();
See what the printf will print out. Let me know the output.
Reply
#4

Output
pawn Код:
[DEBUG] Values: 19.256700,1191.121337,19.150520,0.000000,0.000000,0.000000
Mysql Debug
pawn Код:
[10:47:24] ---------------------------

[10:47:24] MySQL Debugging activated (10/30/13)

[10:47:24] ---------------------------

[10:47:24]  

[10:47:24] >> mysql_query( Connection handle: 1 )

[10:47:24] CMySQLHandler::Query(SELECT * FROM `atm_data`) - Successfully executed.

[10:47:24] >> mysql_store_result( Connection handle: 1 )

[10:47:24] CMySQLHandler::StoreResult() - Result was stored.

[10:47:24] >> mysql_num_rows( Connection handle: 1 )

[10:47:24] CMySQLHandler::NumRows() - Returned 1 row(s)

[10:47:24] >> mysql_fetch_row_format( Connection handle: 1 )

[10:47:24] CMySQLHandler::FetchRow() - Return: 1|1|7|15.4374|1186.98|19.1082|0|0|90

[10:47:24] >> mysql_fetch_row_format( Connection handle: 1 )

[10:47:48] >> mysql_query( Connection handle: 1 )

[10:47:48] CMySQLHandler::Query(INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_Rot_Y,ATM_Rot_Z) VALUES ('1','5','19.256700','1191.1) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1191.1' at line 1)

[10:47:48] >> mysql_free_result( Connection handle: 1 )

[10:47:48] CMySQLHandler::FreeResult() - Result was successfully free'd.
Reply
#5

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
Output
pawn Код:
[DEBUG] Values: 19.256700,1191.121337,19.150520,0.000000,0.000000,0.000000
SQL will assume 0.000 zero's as a NULL Value. If your table's fields are set to NOT NULL. Maybe thats why the query is not INSERT'ing correctly.
Reply
#6

qq stored only this "INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_ Rot_Y,ATM_Rot_Z) VALUES ('1','5','19.256700','1191.1".

So like DanishHaq said, make the size of qq greater.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
qq stored only this "INSERT INTO `atm_data` (AtmExists,Charge,ATM_X,ATM_Y,ATM_Z,ATM_Rot_X,ATM_ Rot_Y,ATM_Rot_Z) VALUES ('1','5','19.256700','1191.1".

So like DanishHaq said, make the size of qq greater.
Yup. Thanks. That worked for him. We just realized it on skype. LOL XD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)