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? ??? Link to comment https://forums.phpfreaks.com/topic/82100-solved-stuck-always-gives-an-error/ 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. Link to comment https://forums.phpfreaks.com/topic/82100-solved-stuck-always-gives-an-error/#findComment-417201 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... Link to comment https://forums.phpfreaks.com/topic/82100-solved-stuck-always-gives-an-error/#findComment-417213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.