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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement

Status
Not open for further replies.

manicleek

Technical User
Joined
Jun 16, 2004
Messages
143
Location
GB
I'm trying to get an image to appear on my page
but only if the image name field is filled in in the db

My code is

Code:
<?php
if ($detailpic2 <> "") {
echo "<img src=\"[URL unfurl="true"]http://www.marinasonline.net/images/marinapics/$detailpic2\"[/URL] align=\"left\" width=\"150\">";<br><br>
}
?>

but I get the error

Parse error: parse error, unexpected '<' in udetails.php on line 56

line 56 being the above code
 
sorry, line 56 is the echo line
 
never mind, its the <br>'s
 
try != instead of <>

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
nipping out to buy some glasses and a slightly longer attention span .....

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Make better use of single and double quotes. Use single quotes to enclose parts of your string that are not dynamic. Include the HTML double quotes for the attributes within the single quotes. Then use concatenation to infuse the variables. Escaped double quotes just make the code extremely unreadable.
Code:
<?php
if ($detailpic2 != "") {
echo '<img src="[URL unfurl="true"]http://www.marinasonline.net/images/marinapics/'.$detailpic2.'"[/URL] align="left" width="150"><br><br>';
}
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top