Need Help with MySQL
#1

Hi guys I am new at MySQL..
I got an error and I tried to fix it but :\ I failed everytime..

The Code
Код:
format(query, sizeof(query), "INSERT INTO `Kicklist` (`Name`,`Reason`, `IP`, `Admin` `KickDate`) VALUES('%s', '%s', %s, '%s' '%d-%d-%d)", GetName(playerid),reason, IP,admin, Year, Month, Date);
	        mysql_query(query);
Error:
Код:
[21:35:35] CMySQLHandler::Query(INSERT INTO `Kicklist` (`Name`,`Reason`, `IP`, `Admin` `KickDate`) VALUES('Japoske', 'HH', 192.168.1.6, 'Japoske' '2014-5-14)) - 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 '`KickDate`) VALUES('Japoske', 'HH', 192.168.1.6, 'Japoske' '2014-5-14)' at line 1)
Somebody Help Please
Reply
#2

you have a missing ' in the KickDate value, and a comma between `Admin` and `KickDate`

Quote:

INSERT INTO `Kicklist` (`Name`,`Reason`, `IP`, `Admin` , `KickDate`) VALUES('%s', '%s', %s, '%s' , '%d-%d-%d')

Reply
#3

"... VALUES('%s', '%s', %s, '%s' '%d-%d-%d)", GetName(playerid) ..." - you forgot a comma before the date and you also forgot to close the apostrofe at the end of the date.

It should be: "... VALUES('%s', '%s', %s, '%s', '%d-%d-%d')", GetName(playerid) ..."
Reply
#4

Код:
for the right syntax to use near '`KickDate`
And if you look in your query at that location you will notice that you missed a comma. It isn't hard, if only one would actually read the error message rather than thinking: "Oh shit! An error! To the SA-MP forums!".
Reply
#5

well bro u are right but it's still not working :\

command:
Код:
format(query, sizeof(query), "INSERT INTO `Kicklist` (`Name`,`Reason`, `IP`, `Admin` ,`KickDate`) VALUES('%s', '%s', %s, '%s', '%d-%d-%d')", GetName(playerid),reason, IP,admin, Year, Month, Date);
	        mysql_query(query);
Error:
Код:
[21:55:20] CMySQLHandler::Query(INSERT INTO `Kicklist` (`Name`,`Reason`, `IP`, `Admin` ,`KickDate`) VALUES('overzode', 'HH', 192.168.1.6, 'overzode', '2014-5-14')) - 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 '.1.6, 'overzode', '2014-5-14')' at line 1)
Reply
#6

Quote:
Originally Posted by Vaishnav
Посмотреть сообщение
pawn Код:
VALUES('%s', '%s', '%s', '%s', '%d-%d-%d')
Try it like this. You forgot one string.
Reply
#7

I am using it by that way but it's not working :\
Reply
#8

... VALUES('%s', '%s', %s, '%s', '%d-%d-%d') ...

It doesn't have apostrophes around %s placeholder.
Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
... VALUES('%s', '%s', %s, '%s', '%d-%d-%d') ...

It doesn't have apostrophes around %s placeholder.
That's what I meant. It works, I have tested it.
Reply
#10

thank guys I really appreciate it and that's my bad I didn't look at that thanks again
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)