Forum Description - Online/Offline Status - PHP

Hello, I own a gaming community called Chillax Gaming and I am trying to set it so before going into a section with the forums for each section, it will say on the description if the server is online or not.

For example

$httpcheck = @fsockopen('your ip address', 80, $error, $errstr, 1);
if ($httpcheck) {
      echo "<img src=\"MyOnlineImageUrl\">";
  } else {
      echo "<img src=\"MyOnlineImageUrl\">";
Would go into the description

How would I get this to work?
It spits out
"; } ?>