PDA

View Full Version : Need help with two things.. PHP+ShoutCast



Fiendly
22-01-2011, 07:28 AM
First things first.
Looking to have the Current DJ/Description outputted onto my webserver. Looking for a small simple code for this, nothing too complex. Anyone know how to do this?

Also:
Any idea on how to refresh a php script without reloading the page, or infact reload a div tag?
Looked at a few scripts but they seem to confusing to my tastes so does anyone know how?

+rep to everyone who helps

tdog360
22-01-2011, 10:25 AM
Firstly, you can use a simple stats script to output the current DJ to your viewers. If it is a log your looking to save, then why not have it send that to the FTP? in a secure directory that only you have access to. Though, like I said, to output DJ Information, all you need is a simple Radio Status PHP scrip, which you can find at http://habboemotion.net under their resources section.

Secondly, you can refresh a php script by using ajax, though personally I don't use much of it. But another solution is to put it in your root directoy (the php file) or whatever directory , though I find the root works best, and then do a php include like so



<?php include('filename.php')?>


if the code above doesn't work just google php includes :)

LMS16
22-01-2011, 10:30 AM
For your shoutcast script, habboemotion should have one...

And as for your refreshing div thing, you can use jquery

put this in your <head></head> tags...



<head>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {
$("#this_div").load("dj_stats.php");
var refreshId = setInterval(function() {
$("#this_div").load("dj_stats.php");
}, 5000); /* 1 second = 1000 */
});

</script>

</head>

<body>
<div id="this_div"></div>
</body>


That will basically load dj_stat.php into that div every 5 seconds...

Enjoy, Lew.

Fiendly
22-01-2011, 11:34 AM
For your shoutcast script, habboemotion should have one...

And as for your refreshing div thing, you can use jquery

put this in your <head></head> tags...



That will basically load dj_stat.php into that div every 5 seconds...

Enjoy, Lew.

Unfortunately thats not working for me..



<html>
<head>
<script type="text/javascript" src="../stats.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {
$("#stats").load("stats.php");
var refreshId = setInterval(function() {
$("#stats").load("stats.php");
}, 5000); /* 1 second = 1000 */
});

</script>

<link rel="icon" href="images/favicon.ico" type="image/x-icon">

<title>Crossfire</title>
</head>

<body>

<div id="stats">
<?php echo $viewerCount; ?>
</div>

</body>
</html>


Am I doing anything wrong? Just getting a blank page..

LMS16
22-01-2011, 11:40 AM
That jquery refresh's a page into a blank div. It doesnt refresh the content inside the div. Put that script on a seperate page and load the shoucats script into it.

You'll work it out :)

Lew.

Want to hide these adverts? Register an account for free!