Valid IP

From: Date: Thu, 26 Sep 2002 16:39:40 +0000
Subject: Valid IP
Groups: php.db 
Request: Send a blank email to php-db+get-22017@lists.php.net to get a copy of this message
Hello guys I know this should be asked in another list but don't want to subcribe just for a simple question. I apologise in advance if that bothers anyone. I'm trying to check valid IPs that come from a form filled by a user so I'm using the following: function valid_ip($ip) { //Check whether it is a valid IP if (ereg("^[1-9]{2,3}+\.[1-9]{2,3}+\.[1-9]{2,3}+\.[1-9]{2,3}+$", $ip)) return true; else return false; } However it just accepts IPs such as xxx.xxx.xxx.xxx Errors arise whith IP such as xxx.xx.xxx.xxx that is every part of the IP should be 3 numbers lenght to be accepted making the function not very handy. Any idea? ******************************************************* Wilmar Pérez Network Administrator Library System Tel: ++57(4)2105145 University of Antioquia Medellín - Colombia 2002 *******************************************************

« previous php.db (#22017) next »