xiao Posted December 17, 2007 Share Posted December 17, 2007 This is my function: function regio($postcode){ switch(TRUE){ case($postcode<1000): //Invalid $regio = 0; break; case($postcode>999 && $postcode<1300): $regio = "Brussel"; break; ..... case($postcode>8999 && $postcode<10000): $regio = "Oost-Vlaanderen"; break; default: //Invalid $regio = 0; break; } return $regio; } And I use this code: $regio = regio($postcode); //Kijken of regio geldig is if($regio == 0){ $msg = "<p class='fail'>Invalid Postal Code!</p>"; }else{ ... I used this to test: $postcode = 2000 I always get the "Invalid Postal Code!" message... Even when I change $regio = 0 in my function to $regio = 1 :-\ I'm sure it's something really noobish, but what am I doing wrong here? ??? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 17, 2007 Share Posted December 17, 2007 Try setting it to "invalid" instead of 0 and then change this if($regio == 0){ to if($regio == "invalid"){ You are mixing strings and integers and that is a bad combo. Quote Link to comment Share on other sites More sharing options...
xiao Posted December 17, 2007 Author Share Posted December 17, 2007 thank you, that's a good lesson weird thing that PHP doesn't give an error or something... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.