Re: Output Errors 2
| From: | David Robley | Date: | Wed, 23 Oct 2002 04:12:05 +0000 |
| Subject: | Re: Output Errors 2 | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22604@lists.php.net to get a copy of this message | ||
In article <200210221805.MAA08355@www2.ebmstpa.com>, biorn@ebmstpa.com
says...
> Unless it is a typo, the line that reads:
>
> if (image == 'NULL') { echo '<p></p></td>'; }
>
> should read:
>
> if ($image == 'NULL') { echo '<p></p></td>'; }
> ^
>
> You forgot the $ in front of image.
>
> HTH
>
> MB
> Bzdpltd@aol.com said:
>
> > Hi sorry back again.
> >
> > Thanks for helping me get the code right. Sorry being stupid again, I am
> having problems with an if / else statement.
> >
> > I am trying the following but it does not seem to work, what the problem
> is, that I am saying if the image name field in the database is empty to
> print nothing, and if it contains data to print that field name, as the a
> href is in the code which pulls the image, if the field is empty it should
> show nothing, but what happens is the image is shown in the browser and its
> not blank.
> >
> > Here is the revised code:
> >
> > echo ("<tr> \n");
> > echo ("<td width=\"72%\"
> > valign=\"top\"><h3>$title</h3> \n");
> > echo ("<p>$description</p></td> \n");
> > echo ("<td width=\"28%\" valign=\"top\">
> > \n");
> > if (image == 'NULL') { echo
> > '<p></p></td>'; }
> > else { echo '<p><img src="' . $image . '"
> > width="201"
> height="160"></p></td>'; }
> > echo ("</tr> \n");
> > }}
> >
> >
> > If someone can see the problem it would be most helpful.
In addition to Maureen's point, you are currently checking whether the
variable $image contains the string NULL; you can test for NULL (without
the quotes) or better, use the function empty() to test whether $image has
a value.
--
David Robley
Temporary Kiwi!
Quod subigo farinam