2016-06-14 14 views
0

und sry im voraus, weil ich neu bin hier und ich bin komplett neu in PHP/Ajax-Codierung.php/ajax vote up down

ich ein kostenloses Skript (Ajax abstimmen up/down) von this site

ich eine einfache PHP-Seite für meine Shoutcast-Server haben den Song zu zeigen gespielt

<?php 
 
\t 
 
\t \t require_once "inc.php"; 
 
\t 
 
\t $array = array(); // Let's store our shoutcast variables into an array. 
 
\t 
 
\t $array['host'] = "xxx.xxx.xx.xxx"; // Your Shoutcast Host 
 
\t $array['port'] = "xxxx"; // Your Shoutcast Port 
 
\t $array['extra'] = "/admin.cgi?sid=1&mode=viewxml&page=1"; // The bit that follows in the url to access the xml of the stats 
 
\t $array['user'] = "xxxxx"; // Admin username (Default is usually "admin") 
 
\t $array['password'] = "xxxxxxx"; // Admin Password 
 
\t 
 
    $radioStats = new radioStats($array['host'], $array['port'], $array['extra'], $array['user'], $array['password']); 
 
\t 
 
    $returnStats = $radioStats->returnStats(); 
 
    $song = $returnStats['currentSong']; 
 
    ?> 
 
<div align="center"> 
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> 
 
</script> 
 
<link href="votingfiles/voting.css" rel="stylesheet" type="text/css" /> 
 
<script src="votingfiles/voting.js" type="text/javascript"></script> 
 
<script> 
 
$(document).ready(function(){ 
 
setInterval(function(){cache_clear()},54000); 
 
}); 
 
function cache_clear() 
 
{ 
 
window.location.reload(true); 
 
} 
 
</script>    
 
\t <div id="radio_stats"> 
 

 
\t <?php 
 
\t \t 
 
\t \t if($returnStats['serverStatus'] != 0) { 
 
\t \t 
 
\t ?> 
 
\t \t <?php 
 
\t \t if($returnStats['currentSong'] != "") { 
 
\t \t \t echo $returnStats['currentSong']; 
 
\t \t } else { 
 
\t \t \t echo "Undefined"; 
 
\t \t } 
 
\t \t ?></div> 
 
\t 
 
\t \t <br /><br /> 
 
\t \t \t \t <div class="vot_updown1" id="vt_$song"></div> \t 
 
\t <?php 
 
\t \t } 
 
\t \t else { 
 
\t ?> 
 
\t This radio server appears to be offline. 
 
\t <?php 
 
\t \t } 
 
\t ?>

Mein Problem ist: Alle Anfrage Php/Ajax/Mysql funktioniert, aber tatsächlich, wenn ich eine Abstimmung mache, ist es in der db wie registriert:

vt_ $ Lied 1 0

Wie kann ich den richtigen Namen des Songs wie das Original php Anfrage erhalten Sie tun:

echo $ returnStats [ 'Current']; oder echo $ song;

vt_Kidd Guti-Step Alles 1 0 (oder jedes anderes Lied gespielt)

Beispiel: [HIER]

Vielen Dank im Voraus für jeden

Um in der db wie registrieren Hilfe.

Antwort

0

In dieser Zeile wird die $song nicht als PHP analysiert so die wörtliche Text $song zeigt:

<div class="vot_updown1" id="vt_$song"></div> 

Versuchen:

<div class="vot_updown1" id="vt_<?php echo $song; ?>"></div> 
+0

Thks viel es jetzt arbeiten! Ich habe versucht, das " albatror

+0

@albatror Hey Freund, wenn die Antwort von Chaim Arbeit ist, bitte akzeptieren Sie die Antwort oder stimmen Sie ab –