Page 1 of 1

Stop php error.

Posted: Tue Jan 04, 2005 8:52 pm
by kenerly
feyd | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


On my web page i have a php script that reports information from my Ghost Recon Gaming Server to the web site and displays it. You can see it at http://christiangamers.net/forum/portal.php mid way down on the left. 

If the Game server is off line. The web page is messed up with the error from not being able to get the data. Can I do something with the script to make it just not report date when the Gaming server is off line?

Code: Select all

<?php

include ("http://24.131.47.214:26/Status/PHPInclude.txt");

?>
            <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#4A473F" id="AutoNumber2" style="border-collapse: collapse">
              <tr>
                <td width="80" class="style6">Active Mods</span></td>
                <td width="131" class="style6">
                  <?php 
	
	foreach ($mods as $i => $value) 
	{
		echo ($mods[$i])."<br>";
	}

	?>
                </span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Map</span></td>
                <td width="131" class="style6"><?php echo $map; ?></span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Mission</span></td>
                <td width="131" class="style6"><?php echo $mission; ?></span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Game Type</span></td>
                <td width="131" class="style6"><?php echo $gameType; ?></span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Game Length</span></td>
                <td width="131" class="style6"><?php echo ((int) $gameLength/60).":".sprintf('%02d',($gameLength - ((int) $gameLength/60)*60)); ?></span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Remaining</span></td>
                <td width="131" class="style6"><?php echo ((int) $remaining/60).":";
						  echo sprintf('%02d', ($remaining - ((int) $remaining/60)*60)); ?></span></td>
              </tr>
              <tr>
                <td width="80" class="style6">Players</span></td>
                <td width="131" class="style6">
<?php 
	
	foreach ($players as $i => $value) 
	{
		echo ($players[$i])."<br>";
	}

	?>                
</span></td>
              </tr>
            </table>

feyd | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Jan 04, 2005 9:05 pm
by feyd

Posted: Tue Jan 04, 2005 9:20 pm
by kenerly
feyd thanks for the link but thats greek to me. What do i add or change to

Code: Select all

<?php

include ("http://24.131.47.214:26/Status/PHPInclude.txt");

?>


To stop the error when server is down?

Posted: Tue Jan 04, 2005 9:24 pm
by feyd
@include(...)

and please read the link in my signature, or the link I added to your original post.

Posted: Tue Jan 04, 2005 9:27 pm
by kenerly
If I add the @ I get ..

Warning: Invalid argument supplied for foreach() in C:\WEB\CGO\forum\cache\MSTrenches\portal_body.php on line 86

Warning: Invalid argument supplied for foreach() in C:\WEB\CGO\forum\cache\MSTrenches\portal_body.php on line 120

Sorry for posting the code wrong, I new at this.

Posted: Tue Jan 04, 2005 9:37 pm
by John Cartwright
where is $mods and $players coming from?

Posted: Tue Jan 04, 2005 10:16 pm
by kenerly
where is $mods and $players coming from?
All Ghost Recon serves report that information. I'm running a program that controls the server operation. The program ask the Ghost Recon server for mods, players, etc and reports it to http://24.131.47.214:26. So the script just gets the data thats reported on that ip, port.

Posted: Tue Jan 04, 2005 10:38 pm
by feyd
try something more like this:

Code: Select all

if(@include( ... ))
{
  // do your display
}
else
{
  // don't do your display, include failed
}