Mysql Query question
#1

Greetings
I am currently trying to set up my samp basic player info in mysql
But i want the ip a player registered on and a recent IP stored both,
So i made 2 diffrent rows, RecentIP and RegisterIP, but the query im using at the moment is not correct i gues..
pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `Admin`, `Vip`, `Money`, `Score`, `XP` ,`RegisterIP`, `RecentIP`)
VALUES ('%e', '%s', 0, 0, 0, 0, 0.0, 0.0, 0.0)"
, Name[playerid], pInfo[playerid][Password], IP[playerid]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);

Full script : http://pastebin.com/EZTEQFz7
Reply
#2

I didnt really understood the inserting function in your code, but, here you go !

http://pastebin.com/ryRR5C21

I've edited the Table Name for IP you can set it as you like, if it doesn't work let me know.
Reply
#3

ShoortyFl i didnt really see what you did, My bad for that, but
All i want is the sql query to be fixed since i don't think it will work like this.
I just want it to store
Username, Password, Admin, Vip, Money, Score, XP, RegisterIP, RecentIP
Thanks.
Reply
#4

Create a table called players, create at least 9 columns, then store the gotten values inside.

What's the problem ?
Reply
#5

Does `RegisterIP` stays always the same? And `RecentIP` is basically the IP player just connected with? Am I right or am I wrong?

edit:// @down,
OnPlayerConnect callback. What is really hard to look for it on your own?
Reply
#6

why are you using %e for username ?

VALUES ('%e', '%s', 0, 0, 0, 0, 0.0, 0.0, 0.0)
Where are you storing the ip[playerid]
Reply
#7

Yes riddick,
Registered ip stays the same and recent ip is the last ip a player connected from, %e is a mysql string anti dql injection
Reply
#8

ok well you'r not storing the ip's
the query must be like
pawn Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `Admin`, `Vip`, `Money`, `Score`, `XP` ,`RegisterIP`, `RecentIP`)
VALUES ('%e', '%s', 0, 0, 0, 0, 0.0, '%s', '%s')"
, Name[playerid], pInfo[playerid][Password], IP[playerid], recentip[playerid]);
Reply
#9

Just insert the same player's IP once they register (IP[playerid] twice as argument) and when they login in the future, execute a query with UPDATE clause
pawn Код:
..., "UPDATE players SET RecentIP='%e' WHERE UserName='%e'", IP[playerid], Name[playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)