MySQL R40 - Insert statement not working
#1

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.
Reply
#2

Increase the size of the query2 cells if mysql logging does not work.
Reply
#3

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.
Reply
#4

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.
Reply
#5

Quote:
Originally Posted by JaskaranSingh
Посмотреть сообщение
Sorry, that was a problem in pasting. The real problem still persists.
Any error/warning logs?
Reply
#6

Quote:
Originally Posted by DelK
Посмотреть сообщение
Increase the size of the query2 cells if mysql logging does not work.
This worked! Thanks a lot.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)