Page 1 of 1

PHP Problem???

Posted: Mon Feb 18, 2013 5:59 am
by PeaseXpress
This Is my first time coding in PHP, I do not use anything other than Notepad to edit things. When I try to open my Minecraft status Checker, it doesn't show the Stats, it just shows me the Code, I.E.,)

[syntax=php]<?php

include ('core/init.inc.php');

?>
<!DOCTYPE html PUBLIC>
<head>
<beta https-equiv="Content-Type" content="text/html; charset=utf-8" />
<style stype='text/css">
table { width: 60px: border-collapse: collapse: }
td, th {padding: 4px: border: solid 1px #444; }
.online { background: #090: }
.offline { background: #900; }
</style>
<title> Minecraft Server Status</title>
<html>
<body>
<table>
<thead>
<tr>
<th>Server</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php

foreach ($servers as $server){
$online = server_online($server[0], $server[1]);

?>
<tr>
<td><?php echo $server[0], ':', $server[1] ?></td>
<td class="<?php echo ($online) ? 'online' : 'offline'"><?php echo ($online) ? 'Online' : 'Offline' ?></td>

</tbody>
</table>
</body>
</html>[/syntax]

I did Make all the other files correctly, but its not working, please contact me at <email withheld> Thanks!!
- PeaseXpress

Re: PHP Problem???

Posted: Mon Feb 18, 2013 6:29 am
by Helx
Is the file saved as a .php?
And are you opening it through a server?

PHP is not like HTML, you can't just open the file in your browser.
Try making an account @ x10hosting.com and upload your files there.

Plus, it'd be worth mentioning that you're missing a few minor details in your code; the foreach loop and both the echo's.
I'd recommend going through the tutorial again, and pay close attention to exactly Jacek does (HD maybe?).

EDIT: Just for future references, you'd get help a lot quicker if you made the post title a tad more descriptive ;)

Re: PHP Problem???

Posted: Mon Feb 18, 2013 4:17 pm
by PeaseXpress
Ok, I will go and try to do that, I wrote this at 11:00 PM, So I was A little tired, Thanks!