You need to escape those "
inside the echoed string (and also remove the ;
after else
):
<table border="1" bgcolor="#fff">
<tr>
<td>SERVER</td>
<?php
$fp = fsockopen("some ip", an port, $errno, $errstr);
if (!$fp)
{
echo "<h1><td style=\"background-color:red\">Offline</td></h1>";
}
else
{
echo "<h1><td style=\"background-color:green\">Online</td></h1>";
fclose($fp);
}
?>
</tr>
</table>