Use trim() instead of that str_replace and then an if(empty())

On Wed, 21 Aug 2002, Jason wrote:

> I have a simplistic forum, and I am trying to write some code to determine
> if the message box actually contains information, because if it is blank I
> obviously don't want to post it to the database. The message box has the
> name of 'reply'. Here is the code I'm trying to use, but its not working:
>
> $reply2 = str_replace(" ","",$reply);
> if(empty($reply2)){
> // echo some error message to the user that they can't post a blank message
> }
> else{
> // post the message
> }
>
> This however didn't work for me. So I had the thought that maybe the
> variable $reply2 isn't set because it is blank. So I tried this:
>
> $reply2 = str_replace(" ","",$reply);
> if(empty($reply2) || !isset($reply2)){
> // echo an error message
> }
> else{
> // post the message.
> }
>
> I've tried different variations on this same idea, but somehow none of them
> are working. Can anyone give me any suggestions or insight?
>
> Jason Cathcart
> Check Out My Site: http://www.biohazardous.org
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to