PHP Problem???

Ask about a PHP problem here.
Post Reply
PeaseXpress
Posts: 2
Joined: Mon Feb 18, 2013 5:54 am

PHP Problem???

Post 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
Last edited by Helx on Mon Feb 18, 2013 6:22 am, edited 2 times in total.
Reason: Remember to use code tags (quick tip, never put your email in forums)
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: PHP Problem???

Post 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 ;)
PeaseXpress
Posts: 2
Joined: Mon Feb 18, 2013 5:54 am

Re: PHP Problem???

Post 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!
Post Reply