Stop php error.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kenerly
Forum Newbie
Posts: 4
Joined: Tue Jan 04, 2005 8:47 pm

Stop php error.

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

kenerly
Forum Newbie
Posts: 4
Joined: Tue Jan 04, 2005 8:47 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

@include(...)

and please read the link in my signature, or the link I added to your original post.
kenerly
Forum Newbie
Posts: 4
Joined: Tue Jan 04, 2005 8:47 pm

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

where is $mods and $players coming from?
kenerly
Forum Newbie
Posts: 4
Joined: Tue Jan 04, 2005 8:47 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try something more like this:

Code: Select all

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