Jump to content

[SOLVED] Prototype Ajax.PeriodicalUpdater Not Working


joshedgar

Recommended Posts

Hey PHPFreaks,

 

Trying to get this script to work. Basically, it updates internet radio station requests without a refresh, every few seconds. It worked before in a different page, all I did was copy paste the code into a different page, and it doesn't work there. Code is below. When run, it shows the requests that are in the database, but then in the blink of an eye they disappear (as if when PeriodicalUpdater refreshes that <div>, the database got emptied, when it didn't).

 

$_GET['full'] is the stations full name, which is delivered via the URL

$_GET['ch'] is the "short name" for the station, the way it's keyed in the database.

 

The page that displays them:

 

<?php
$con2 = mysql_connect("localhost", "thisistheusername", "thisisthepassword");
if(!$con2)
{
die(mysql_error());
}
mysql_select_db("cyberfm_site", $con2);
?>
<html>
<head>
<title>CyberFM Requests</title>
<script type="text/javascript" src="prototype-1.6.0.3.js"></script>
<script type="text/javascript">
new Ajax.PeriodicalUpdater('rqview', 'requests_query.php', {
  method: 'get', frequency: 5
});
</script>
<style type="text/css">
body {
background: #EEEEEE;
}
</style>
</head>
<body>
<strong><i>CyberFM Requests Viewer</i></strong><br />
<i><?php echo $_GET['full']; ?></i><br />
<div id="rqview">
<?php @include("requests_query.php"); ?>
</div>
</body>
</html>
<?php mysql_close($con2); ?>

 

requests_query.php :

 

<?php
$con = mysql_connect("localhost", "thisistheusername", "thisisthepassword");
if(!$con)
{
die(mysql_error());
}
mysql_select_db("cyberfm_site", $con);
?>
<table id="requests2" align="center" width="550" border="1" style="font-family: Verdana; font-size: 13px;">
	<tr>
		<td><strong>Name</strong></td>
		<td><strong>Artist</strong></td>
		<td><strong>Song</strong></td>
		<td><strong>Dedication</strong></td>
	</tr>
<?php
$rqs = mysql_query("SELECT * FROM requests WHERE Channel='".mysql_real_escape_string($_GET['ch'])."' ORDER BY id DESC;", $con);

while($rqr = mysql_fetch_array($rqs))
{
?>
	<tr>
		<td><?php echo $rqr['Sender']; ?><br /><?php echo $rqr['IPAddress']; ?></td>
		<td><?php echo $rqr['Artist']; ?></td>
		<td><?php echo $rqr['Song']; ?></td>
		<td><?php echo $rqr['Dedication']; ?></td>
	</tr>
<?php
}
?>
</table>
<?php mysql_close($con); ?>

 

Note: "thisistheusername" and "thisisthepassword" in mysql_connect() are in the script with my actual username and password.

 

Anyone have any ideas? Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.