Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple db question - Checking for Null 1

Status
Not open for further replies.

Zych

IS-IT--Management
Apr 3, 2003
313
US
Hello All,

I am new to PHP but I have used ColdFusion a long time ago. I want to check for Null in a database and depending on if it is or not echo certain output. Here is an example of what I have tried so far but it does not seem to work.

<!-- Checks to see if URL is available if yes make company linkable, if not just echo company name. -->
if ($row->Web != Null) {
echo "<a href='$row->Web' target='_blank'>$row->Company</a><br>";
} else {
echo "$row->Company<br>";}

<!-- If first line of address exists, echo it. -->
if ($row->Add1 != Null) {
echo "$row->Add1<br>";}

<!-- If second line of address exists, echo it. -->
if ($row->Add2 != Null) {
echo "$row->Add1<br>";}

<!-- If city exists, echo city, state and zip. -->
if ($row->City != Null) {
echo "$row->City, $row->State $row->Zip";}

I am just checking to see if an address or URL is available and if so I echo the results. What am I doing wrong? My book does not cover this very well so I need to ask the experts.

Thanks,

Zych
 
There is a constant in PHP: NULL
It's all uppercase - PHP is case specific.
 
Thank you for the quick reply. (I only had time to get a glass of water) It worked like a charm. A star for you!

- Zych
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top