3raser Posted July 23, 2010 Share Posted July 23, 2010 On my code, about lines 35-53, I did this: if($action==1) { $number_messages = $_POST['number']; $message = $_POST['message']; if($number_messages < 200) { echo "The maximum message amount is 200."; } else { echo "Your message has been duplicated by ". $number_messages ." times.<br/><br/>"; for($i = 0; $number_messages > $i; $i++) { echo $message."<br/>"; } } } If $number_messages is above 200, it still doesn't say you've exceeded the maximum. The full code is right here: <?php echo "<center><a href='index.php'>Home</a> | <a href='index.php?page=1'>BBcode to HTML</a> | <a href='index.php?page=2'>Make a big message</a></center><hr>"; $page = $_GET['page']; $page_p = $_POST['page']; $action = $_POST['action']; if(!$page && !$page_p) { echo "Welcome to our site! On this site you can find a varity of cool scripts that can help you on certain things, or just entertain you. "; } elseif($page==1 || $page_p==1) { echo "You can easily use this script to change forum BBCodes into HTML.<br/><br/>"; if($action==1) { $before = $_POST['before']; $change_this = array('[b]','[b]','[/b]','[/b]','[img=','[img]',']', '[/img]'); $after = array('<b>', '<b>', '</b>','</b>','<img src="', '<img src="','">', '">'); $output = str_replace($change_this, $after, $before); echo "Before: ". $before ."<br/><br/><br/>After </br><textarea rows='30' cols='100'>". $output ."</textarea>"; } else { echo "<form action='index.php' method='POST'>BBCode Text<br/> <input type='hidden' name='action' value='1'><input type='hidden' name='page' value='1'> <textarea name='before' cols='70' rows='20'></textarea><br/><input type='submit'></form>"; } } elseif($page==2 || $page_p==2) { if($action==1) { $number_messages = $_POST['number']; $message = $_POST['message']; if($number_messages < 200) { echo "The maximum message amount is 200."; } else { echo "Your message has been duplicated by ". $number_messages ." times.<br/><br/>"; for($i = 0; $number_messages > $i; $i++) { echo $message."<br/>"; } } } else { echo "<form action='index.php' method='POST'>Message: <input type='text' name='message' maxlength='50'> Number: <input type='text' name='number' length='10'> <input type='hidden' name='page' value='2'><input type='hidden' name='action' value='1'><input type='submit' value='Create'> </form>"; } } else { echo "Your on an unknown page."; } if(!$page && !$page_p) { echo "<br/><br/><br/>Your currently on the main page."; } elseif(!$page && $page_p) { echo "<br/><br/><br/><br/>Your currently on page ".$page_p; } elseif(!$page_p && $page) { echo "<br/><br/><br/><br/>Your currently on page ".$page; } else { echo "<br/><br/><br/>Your currently on an unknown page."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/ Share on other sites More sharing options...
dezkit Posted July 23, 2010 Share Posted July 23, 2010 if($number_messages > 200) Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090318 Share on other sites More sharing options...
3raser Posted July 23, 2010 Author Share Posted July 23, 2010 if(strlen($number_messages) < 200) Thanks for the help, but thats not the problem. $number_messages is an integer, so I'm seeing if they entered in a number greater than 200. Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090320 Share on other sites More sharing options...
dezkit Posted July 23, 2010 Share Posted July 23, 2010 read edited post, Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090321 Share on other sites More sharing options...
3raser Posted July 23, 2010 Author Share Posted July 23, 2010 if($number_messages > 200) I'm not checking to see if they entered in something smaller. I'm trying to see if they entered in something greater than 200, and if they did, it gives them the error message. Else, everything works and they don't get an error message. Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090326 Share on other sites More sharing options...
dezkit Posted July 23, 2010 Share Posted July 23, 2010 dude, its checking if the string is GREATER than 200... Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090328 Share on other sites More sharing options...
3raser Posted July 23, 2010 Author Share Posted July 23, 2010 dude, its checking if the string is GREATER than 200... Thats what I want it to do. I want it to check and see if they typed in a number greater than 200, if they did, give them the error message. But when I keep trying it on my website, it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090332 Share on other sites More sharing options...
radar Posted July 23, 2010 Share Posted July 23, 2010 Well, what does $_POST['number'] output when you type in 201? Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090333 Share on other sites More sharing options...
jcbones Posted July 23, 2010 Share Posted July 23, 2010 > equals "greater than" < equals "less than" The point always points at the lower value. if($number_messages < 200) { echo "The maximum message amount is 200."; //IF $number_messages is LESS THAN 200, print this message. } Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090402 Share on other sites More sharing options...
radar Posted July 23, 2010 Share Posted July 23, 2010 But by your account jcbones, the users would be seeing that maximum message ammount error until they hit 200 messages.. which will be never since its an error.. so his checking of greater than is correct. because he wants to find messages above 200 not below 200. Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090413 Share on other sites More sharing options...
dezkit Posted July 23, 2010 Share Posted July 23, 2010 But by your account jcbones, the users would be seeing that maximum message ammount error until they hit 200 messages.. which will be never since its an error.. so his checking of greater than is correct. because he wants to find messages above 200 not below 200. well said Quote Link to comment https://forums.phpfreaks.com/topic/208702-why-doesnt-it-say-youve-exceeded-the-maximum-amount/#findComment-1090414 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.