Formatting a query
#1

Hey, I've ran into a small problem which I can't figure out why it happens..
I want to fetch all the accounts under a given IP range, and I've scripted the necessary things for it. When I format the query, it leaves the range format (%..%).
1. I used this code:
pawn Код:
format(gQuery, sizeof gQuery, "SELECT `Username`, `IP` FROM `"Users_Table"` WHERE `IP` LIKE '%%s%'", inputtext);
The inputtext was 127.0. and it printed "127.0." and not %127.0.%
2. I used this code:
pawn Код:
new ip[18];
format(ip, sizeof ip, "%s", inputtext);
format(gQuery, sizeof gQuery, "SELECT `Username`, `IP` FROM `"Users_Table"` WHERE `IP` LIKE %'%s'%", ip);
The inputtext was 127.0. and it printed "127.0.%" in the console (% = #, in console)

Am I doing something wrong, or isn't that the way to use such query?
Reply


Messages In This Thread
Formatting a query - by biker122 - 03.09.2016, 13:47
Re: Formatting a query - by Stinged - 03.09.2016, 13:56
Re: Formatting a query - by jlalt - 03.09.2016, 14:00
Re: Formatting a query - by Stinged - 03.09.2016, 14:08
Re: Formatting a query - by biker122 - 03.09.2016, 14:15

Forum Jump:


Users browsing this thread: 2 Guest(s)