joshedgar Posted July 9, 2009 Share Posted July 9, 2009 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! Quote Link to comment Share on other sites More sharing options...
joshedgar Posted July 10, 2009 Author Share Posted July 10, 2009 Figured it out, never had to do this before, but adding ?ch=(the short name) into the AJAX request appeared to fix it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.