Need Help with MySQL -
Vaishnav - 14.05.2014
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
Re: Need Help with MySQL -
Kirollos - 14.05.2014
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')
|
Re: Need Help with MySQL -
Konstantinos - 14.05.2014
"... 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) ..."
Re: Need Help with MySQL -
Vince - 14.05.2014
Код:
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!".
Re: Need Help with MySQL -
Vaishnav - 14.05.2014
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)
Re: Need Help with MySQL -
Madd92 - 14.05.2014
Quote:
Originally Posted by Vaishnav
pawn Код:
VALUES('%s', '%s', '%s', '%s', '%d-%d-%d')
|
Try it like this. You forgot one string.
Re: Need Help with MySQL -
Vaishnav - 14.05.2014
I am using it by that way but it's not working :\
Re: Need Help with MySQL -
Konstantinos - 14.05.2014
... VALUES('%s', '%s',
%s, '%s', '%d-%d-%d') ...
It doesn't have apostrophes around
%s placeholder.
Re: Need Help with MySQL -
Madd92 - 14.05.2014
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.
Re: Need Help with MySQL -
Vaishnav - 14.05.2014
thank guys

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