1 Nov 2004 05:01
Re: IP regex
Vladimir V. Kolpakov <w <at> sfgate.com>
2004-11-01 04:01:09 GMT
2004-11-01 04:01:09 GMT
On Sun, Oct 31, 2004 at 02:02:26PM -0500, Michael Stassen wrote:
> My advice: It makes no sense to keep IPs in a VARCHAR(30) column. (Even if
> a string was the right way to go, you'd need at most 15 characters.) The
> better way is to use an INT UNSIGNED. Then you store an IP using
> INET_ATON(IP) and retrieve it with INET_NTOA(ip_column). That takes 4
> bytes instead of 8 to 16, and reduces the likelihood of garbage values in
It's very common mistake, --
to think integer occupies in databases 4 bytes.
Please look DESC on your table, and you can find
it takes 11 bytes, because is stored in character form.
> >>>I have been given the chore of taking a DB table of client records,
> >>>which has a field called IP address. Whenever a client logs onto our
> >>>site, I'm supposed to display the IP address they logged on from THE
> >>>LAST TIME they visited, as a security measure.
> >>>Can someone point me in the direction of creating REGEX to test whether
> >>>an IP address is valid. (Valid in the sense of syntax i.e.
> >>>192.168.24.20 is valid, but
> >>>277.22.49.75, or 65.23 is not)?
> >>>Gregg Allen
Gregg, --
Why you need to check IP addr, anyway?
If it comes from apache cgi's $ENV{REMOTE_ADDR},
and user input does not affect on it,
what's the reason for regex-ing?
(Continue reading)
RSS Feed