chocopi Posted May 16, 2007 Share Posted May 16, 2007 ok i would like to have a script where a variable is set a value and when something is done it is added to or taken away from. <?php $errors = 0; if ( strlen($username) > 5) { echo ("Your username must be longer than 5 characters. <br />"); $errors = ++1; } ?> This doesnt work so i was wondering what changed i would need to do. Cheers, ~ Chocopi Quote Link to comment Share on other sites More sharing options...
papaface Posted May 16, 2007 Share Posted May 16, 2007 It should be $errors++ Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 16, 2007 Share Posted May 16, 2007 <?php $errors = 0; if ( strlen($username) > 5) { echo ("Your username must be longer than 5 characters. <br />"); $errors += 1; } ?> Try that Quote Link to comment Share on other sites More sharing options...
chigley Posted May 16, 2007 Share Posted May 16, 2007 <?php $errors = 0; if ( strlen($username) < 5) { echo ("Your username must be longer than 5 characters. <br />"); $errors++; } ?> You had your < the wrong way round, and I've changed the code to add one Quote Link to comment Share on other sites More sharing options...
chocopi Posted May 16, 2007 Author Share Posted May 16, 2007 Thanks for the speedy help (Thanks for the typo their aswell ) ~ Chocopi 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.