Re: EMPTY??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I did a simple test like this on my save page:

<?php
$comments = $_POST['comments'];
echo "0000".$comments."0000";
?>

And it returns 00000000

So, that should show me that there are no place holders, no characters, and
no carriage returns for the value of $comments, correct?


On 10/23/07, David Giragosian <dgiragosian@xxxxxxxxx> wrote:
>
>  On 10/23/07, Dan Shirah <mrsquash2@xxxxxxxxx > wrote:
> >
> > I am having some issues with empty().
> >
> > On my page I have a text area:
> >
> > <table align="center" border="0" cellpadding="0" cellspacing="0"
> > width="680">
> > <tr>
> > <td width="600" align="center"><span class="inputlbl">Comments:
> >      <textarea name="comments" tabindex="39" rows="3" cols="45"
> > wrap="soft"></textarea>
> >      </span> </td>
> > </tr>
> > </table>
> >
> > I then submit my page and on the following page I put the posted value
> > into
> > two variables.
> >
> > $comments = strtoupper($_POST['comments']);
> > $check_comments = $_POST['comments'];
> >
> > I made two variables for the same posted value because I believe empty()
> > does not work with strtoupper in front of the value. It only works with
> > a
> > standalone variable, correct?
> >
> > So, once I have assigned my comments to a variable I am doing:
> >
> > if(!empty($check_comments)) {
> > echo "Do Something";
> > }
> >
> > However, if the comments textarea is left blank I just get a generic
> > error
> > "Changed database context to database"
> >
> > I've tried the below and get the same result:
> > if($check_comments != "") {
> > echo "Do Something";
> > }
> >
> > When comments is left blank and I echo out the value for $check_comments
> > it
> > returns nothing at all which is why I think empty() or "" should work,
> > but
> > they don't.
> >
> > Ideas?
>
>
> I've been tripped up by spaces in text fields/boxes, so I've learned to
> trim before testing for strlen == 0.
>
> strtoupper returns a string. If there were a zero-length string in the
> textarea, I'd guess it would return a zero-length string.
>
> Are you sure there are no carriage returns, etc... in your textarea ?
>
> David
>
>
>
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux