On 22/08/07, M. Sokolewicz <[EMAIL PROTECTED]> wrote:
>
> I'm pretty sure
> if(!empty($result_deferred_comments)) {
>
> does something else than you think it does.
> $result_deferred_comments = mssql_query($deferred_comments) or
> die(mssql_error());
>
> if it fetches any rows it will return a RESOURCE (yes, a resource which
> is NEVER empty()), if it has 0 rows, it will return TRUE(yes! Again
> non-empty), if it errors, it will return false (yes, empty).
>
> Instead, use
> if(false !== $result_deferred_comments && true !==
> $result_deferred_comments){


Minor addition; you actually want to know if the result value is a resource
or a boolean. So, why not use 'is_resource' ?

Apart from having shorter lines of code I usually prefer checking for
something that's true, but maybe that's a personal thing ;-)

Dan Shirah wrote:
> > From my understanding, if $result_deferred_comments is empty, than none
> of
> > the code below the if should be executed, correct?
> >
> > The actualy rows/columns that would contain the data do not appear, but
> I am
> > still seeing the "DEFERRED PAYMENT REQUEST COMMENTS" table. Is the only
> way
> > to block out EVERYTHING from being displayed if
> $result_deferred_comments is
> > empty to use " " around all of the HTML and not exit out of the PHP
> tags?
> > Or am I doing something else wrong?
> >
> > Or, is it a problem with (!empty())?  Since the value is an array, will
> it
> > never be parsed as empty even if there is no data retrieved?
> >
> > Below is my code:
> >
> > <?php
> > $credit_card_id = $_GET['credit_card_id'];
> >
> > $deferred_comments= "SELECT * FROM comments WHERE credit_card_id =
> > '$credit_card_id' AND request_type = 'D'";
> > $result_deferred_comments = mssql_query($deferred_comments) or
> > die(mssql_error());
> >
> > if(!empty($result_deferred_comments)) {
> > ?>
> > <table width="700" border="1" align="center">
> >   <tr>
> >     <td bgcolor="#FF9900">
> > <div align="center"><strong>DEFERRED PAYMENT REQUEST
> > COMMENTS</strong></div></td>
> >   </tr>
> > </table>
> > <table width="700" border="0" align="center">
> > <?php
> > while ($row_deferred_comments =
> > mssql_fetch_array($result_deferred_comments)) {
> >    $id_deferred_comment = $row_deferred_comments['request_id'];
> >    $dateTime_deferred = $row_deferred_comments['comment_date'];
> >    $deferred_comments = $row_deferred_comments['comments'];
> >    $deferred_wrap_comments = wordwrap($deferred_comments, 60, "<br
> />\n");
> > ?>
> > <tr>
> >     <td width='108' height='13' align='center' bgcolor="#FFD9C6"
> > class='tblcell'>
> >       <div align='center'><?php echo "$id_deferred_comment"
> ?></div></td>
> >     <td width='148' height='13' align='center' bgcolor="#FFD9C6"
> > class='tblcell'>
> >       <div align='center'><?php echo "$dateTime_deferred" ?></div></td>
> >     <td width='444' height='13' align='center' bgcolor="#FFD9C6"
> > class='tblcell'>
> > <div align='left'><?php echo $deferred_wrap_comments; ?></div></td>
> > </tr>
> > <?php } ?>
> > </table>
> > <?php } ?>
> >
> > Thanks,
> > Dan
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Interpotential.com
Phone: +31615397471

Reply via email to