MySQL R40 - Insert statement not working -
JaskaranSingh - 30.01.2018
I am trying to insert data into the table and these statements work as expected:
Код:
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `admins` (`pId`, `pName`, `pAdmin`, `aTime`, `aStatus`) VALUES ('%d', '%e', '%d', '%d', 1)", PlayerInfo[id][pId], pName2, level, timestamp);
mysql_tquery(g_SQL, query, "", "");
But when I try to execute this:
Код:
mysql_format(g_SQL, query2, sizeof(query2), "INSERT INTO `bans` (`pId`, `pName`, `bIp`, `bReason`, `bTime`, `pBanned`, `bExpiration`) VALUES ('%d', '%e', '%e', '%e', '%d', 1, 8000)", PlayerInfo[id][pId], pName2, pIp, reason, timestamp);
mysql_tquery(g_SQL, query2, "", "");
Nothing works. If I execute the query using only first columns, then it works perfectly fine. If I execute using only last two, it still works good, but when I execute them together, no data is inserted.
I have checked the database. There is no problem. I am matched the data types.
I am stuck into this weird problem since last three days. Please help.
Re: MySQL R40 - Insert statement not working -
DelK - 30.01.2018
Increase the size of the query2 cells if mysql logging does not work.
Re: MySQL R40 - Insert statement not working -
Wanheda - 30.01.2018
You are trying to insert 6 values while writing only 5 variables. (missing pBanned)
And by the way, you can just use:
Код:
mysql_query(g_SQL, query);
Also, please check your mysql logs and see if anything is printed.
Re: MySQL R40 - Insert statement not working -
JaskaranSingh - 30.01.2018
Quote:
Originally Posted by Wanheda
You are trying to insert 6 values while writing only 5 variables. (missing pBanned)
And by the way, you can just use:
Код:
mysql_query(g_SQL, query);
Also, please check your mysql logs and see if anything is printed.
|
Sorry, that was a problem in pasting. The real problem still persists.
Re: MySQL R40 - Insert statement not working -
Wanheda - 30.01.2018
Quote:
Originally Posted by JaskaranSingh
Sorry, that was a problem in pasting. The real problem still persists.
|
Any error/warning logs?
Re: MySQL R40 - Insert statement not working -
JaskaranSingh - 30.01.2018
Quote:
Originally Posted by DelK
Increase the size of the query2 cells if mysql logging does not work.
|
This worked! Thanks a lot.
Re: MySQL R40 - Insert statement not working -
JaskaranSingh - 30.01.2018
Quote:
Originally Posted by Wanheda
Any error/warning logs?
|
Yes, the error was something like:
The destination size [128] is too small, so I increased it to 512 and it worked like a charm.