PDA

View Full Version : MYSQL is not inserting


idegod
23/05/2018, 07:16 PM
Why this query is not inserting?


mysql_format(ConnectMYSQL, query, sizeof(query), "INSERT INTO `mt` (`player`, `killers`, `date`) VALUES ('%d', '%s', '%s')", playerid, strkillers, datestr);
mysql_query(ConnectMYSQL,query);


table

player int(11)
killers text
date varchar(20)


playerid = playerid

datestr

new datestr[128];
new Year, Month, Day;
getdate(Year, Month, Day);
format(datestr, sizeof(datestr), "%02d/%02d/%d", Day, Month, Year );


killers
...for:

new kstr[128];
if(killerid != INVALID_PLAYER_ID) {
printf("OI");
format(kstr, sizeof(kstr), "<a href='player.php?p=%s'>%s</a> ", PlayerName(killerid), PlayerName(killerid) );
printf("kstr: ", kstr);
}


after for

strcat(strkillers, kstr);

FailerZ
23/05/2018, 07:22 PM
Check the logs, are there any errors?
I suspect it could be the size/length of the query string variable, try increase it if it is low.

idegod
24/05/2018, 01:10 AM
[21:05:44] [ERROR] error #1064 while executing query "INSERT INTO `mt` (`player`, `killers`, `date`) VALUES ('110', '<a href='char.php?p=Indiny'>Indiny</a> ', '23/05/2018')": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'char.php?p=Indiny'>Indiny</a> ', '23/05/2018')' at line 1 (CNR.pwn:2871 -> CNR.pwn:4618)


I didnt know about this logs, i search and found it, what i supposed to do?

GTLS
24/05/2018, 09:11 AM
Change,

format(kstr, sizeof(kstr), "'<a href=player.php?p=%s>%s</a>'", PlayerName(killerid), PlayerName(killerid) );

and

mysql_format(ConnectMYSQL, query, sizeof(query), "INSERT INTO `mt` (`player`, `killers`, `date`) VALUES (%d, %s, '%s')", playerid, strkillers, datestr);
mysql_query(ConnectMYSQL,query);

idegod
24/05/2018, 03:50 PM
Change,

format(kstr, sizeof(kstr), "'<a href=player.php?p=%s>%s</a>'", PlayerName(killerid), PlayerName(killerid) );

and

mysql_format(ConnectMYSQL, query, sizeof(query), "INSERT INTO `mt` (`player`, `killers`, `date`) VALUES (%d, %s, '%s')", playerid, strkillers, datestr);
mysql_query(ConnectMYSQL,query);

Thank you so much! +rep

Logic_
24/05/2018, 04:09 PM
Which version of MySQL are you using dude, you must make use of the threaded queries.