PHP If Statement not working

Soldato
Joined
30 Nov 2005
Posts
3,084
Location
London
Having a problem with an IF statement in PHP. It seems to think that the string stored in the variable is less than six when it's not.

When I echo the $something the value is longer than six yet it still seems to think that it's not and dies.

Any ideas?

Code:
if($something < 5){
die(include "toosmall.php");
}
 
Last edited:
Right, I echoed the $something before the IF statement is run and its prints the correct value.

I also echoed AFTER the IF statement is run and no value is printed.

Hmmmmmmmmmmm.......
 
i must say, that's a bizarre way of working. are you not going to end up with a dozen scripts for one form?? :confused: :p

Do you mean if I run this to check each string?

Would there be an easier method?

Edit: Silly me, I remember functions! So how would I create a function for the above that I could use on different variable names?
 
Last edited:
Why not just echo whatever toosmall.php contains?

Or is there a specific reason why it's in a separate file?

Jon
 
i've just had a quick look at your other thread - is this for a user registration form? i'd put the html form and the php in the same page and have it submit to it's self. then if any field fails validation, the form is displayed (with a little message to prompt the user on what they need to do to correct it). only when all fields pass validation, you can then update the database and redirect to a success page.
 
Back
Top Bottom