GetPlayerIP help
#1

Hey guys well I use MySQL and i've just finished making my ban cmd for saving the players IP, User and reason to a table called Banned, but for some reason. It saved the IP as 55. Any idea why that is? Heres the code

pawn Код:
new ip[16];

GetPlayerIp(id, ip, sizeof(ip));
format(query, sizeof(query), "INSERT INTO `Banned` (`User`, `Reason`, `IP`) VALUES ('%s', '%s', '%d')", pname, reason, ip);

mysql_query(query);
Reply
#2

Ip is characters, not integer

pawn Код:
new ip[16];

GetPlayerIp(id, ip, sizeof(ip));
format(query, sizeof(query), "INSERT INTO `Banned` (`User`, `Reason`, `IP`) VALUES ('%s', '%s', '%s')", pname, reason, ip);

mysql_query(query);
Reply
#3

IP is a string, not an integer.
Replace %d with %s

Edit: I was too late
Reply
#4

So should I make the field a text / varchar too?
Reply
#5

Yes the field should be a varchar having length of 16
Reply
#6

Ok thanks for both your helped, although you were late in replying i'll rep you any way for giving me a hand.

Edit:

It won't let me rep you Dwane, sorry.
Reply
#7

lol LiamM. I don't care about Reputation.
Your Welcome!
Reply
#8

Quote:
Originally Posted by Dwane
Посмотреть сообщение
lol LiamM. I don't care about Reputation.
Your Welcome!
Yeah thats sweet, a lot of people do and a lot of people treat it like money lol.. Free way to gain knowledge about something you know?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)