I want to only display an echo statement if a cell is not set to null. I have the following code but keep getting an "HTTP ERROR 500" error when rendering my page since including this conditional statement.
$res=mysql_query("SELECT * from Stores");
<p class="description"><?php echo $row["Address1"];?><br />
<?php
$test=$row["Address2"];
if (isset($test)) {
echo $row["Address2"]<br />;
}?>
<?php echo $row["City"];?>, <?php echo $row["State"];?> <?php echo $row["Zip"];?></p>
I have also tried
if($row["Address2"] != NULL)
as my conditional statement, getting the same error. Can anyone tell me what I am doing wrong?
TIA
This is a syntax error in PHP:
echo $row["Address2"]<br />;
You forgot to enclose the HTML string in quotes:
echo $row["Address2"] . "<br />";
Also, $row
is not being populated, so even if you fix the typo, it won't work for other reasons.