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 Link to comment https://forums.phpfreaks.com/topic/51711-solved-adding-variables/ Share on other sites More sharing options...
papaface Posted May 16, 2007 Share Posted May 16, 2007 It should be $errors++ Link to comment https://forums.phpfreaks.com/topic/51711-solved-adding-variables/#findComment-254741 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 Link to comment https://forums.phpfreaks.com/topic/51711-solved-adding-variables/#findComment-254742 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 Link to comment https://forums.phpfreaks.com/topic/51711-solved-adding-variables/#findComment-254743 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 Link to comment https://forums.phpfreaks.com/topic/51711-solved-adding-variables/#findComment-254746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.