2012-12-17 42 views
0

我有一個非常奇怪的事情在這裏。我有一個叫做index2.php的php文件(我會給出下面的代碼)我有這個文件在兩個不同的目錄中,當我加載的時候,然後在我的Web瀏覽器中,我得到兩個不同的輸出。有人可以告訴我這是怎麼可能的!?相同的php文件,但在不同的文件夾中顯示不同的輸出

<?php 
////////////////////////////////////////////////////////////////// 
// DJ Status v3.0            // 
// ©2012 Joseph Scocca           // 
////////////////////////////////////////////////////////////////// 
include ("config.php"); // include the settings to connect to DB and ShoutCast 
include ("header.php"); // include the Header info 
if ($scsuccs!=1) { // Check is we can connect to ShoutCast Server 
if($streamstatus == "1"){ // Is the Stream broadcasting 
if (isset($dj)) { // is there a DJ in the DB connected 

// Open Container and Column 1 
echo "<div id=\"container\"><div id=\"column-1\">"; 

// connected DJ have a Avatar 
if (isset($djavatar) && $djavatar) { echo " 
<div id=\"avatarpic\"><img src=\"$djavatars/$djavatar\" /></div>"; }  

// Close Column 1 Open Column 2 Make the Div Stats and start showing data 
echo "</div><div id=\"column-2\"> 
<div id=\"stats\"> 
<div><strong><span>Now playing</span></strong></div>"; 


// if the song title is longer than 17 characters then scroll the title 
if (strlen($artisttitle[1]) > 17) { echo " 
<div><marquee behavior=\"scroll\" scrollamount=\"1\" direction=\"left\" width=\"160\">$artisttitle[1]</marquee> </div>"; 

// if the artist is longer than 16 characters then scroll the artists 
if (strlen($artisttitle[0]) > 16) { echo " 
<div><strong>By </strong><marquee behavior=\"scroll\" scrollamount=\"1\" direction=\"left\" width=\"135\">$artisttitle[0] </marquee></div> 
<div><strong>On Air</strong> $djname </div>"; 

// if the artist is short than or equals 16 characters then just display it as text 
} else if (strlen($artisttitle[0]) <=16) { echo " 
<div><strong>By </strong>$artisttitle[0]<div> 
<strong>On Air</strong> $djname </div>";} 

} else if (strlen($artisttitle[1]) <= 17) {  
echo "<div>$artisttitle[1]</div>"; 
//if the song title is less than 17 characters then just display it as text 

// if the artist is longer than 16 characters then scroll the artists 
if (strlen($artisttitle[0]) > 16) { echo " 
<div><strong>By </strong><marquee behavior=\"scroll\" scrollamount=\"1\" direction=\"left\" width=\"135\">$artisttitle[0]</marquee></div><div><strong>On Air</strong> $djname </div>"; 
    // if the artist is short than or equals 16 characters then just display it as text 
} else if (strlen($artisttitle[0]) <=16) { echo " 
<div><strong>By </strong>$artisttitle[0]<div><strong>On Air</strong> $djname </div>"; 
      } 
    } 
echo "</div></div></div> // Close Column 2, Stats, and Container. 
<div id=\"column-3\"><div id=\"social\">"; // Open Column 3 and social 
    if (isset($address) && $address) {echo " 
<a href=\"$address\" target=\"_blank\"> 
<img style=\"height:25px;width:94px;\" src=\"images/request.png\" border=\"0\" /> 
</a><br>";} // requestline 

if (isset($djname1) && $djname1) {echo " 
$djname1";} // Display the DJ Name (for shows that Have a Co Host.) 
if (isset($twitter) && $twitter) {echo " 
<a href=\"http://www.twitter.com/$twitter\" target=\"_blank\"> 
<img src=\"images/twitter.png\" border=\"0\" /></a>";} 
    // does the DJ have a Twitter, if so display it 

if (isset($facebook) && $facebook) {echo " 
<a href=\"http://www.facebook.com/$facebook\" target=\"_blank\"> 
<img src=\"images/facebook.png\" border=\"0\"/></a>"; } 
// does the DJ have a Facebook, if so display it 

if (isset($email) && $email) {echo " 
<a href=\"mailto:$email\"><img src=\"images/email.png\" border=\"0\"/></a>";} 
    // does the DJ have a Email, if so display it 

// if the Connected DJ has a Co Host do the following. 
if (isset($djname2) && $djname2) {echo " 
<br />$djname2";} // Display the Co Host Name 

if (isset($twitter2) && $twitter2) {echo " 
<a href=\"http://www.twitter.com/$twitter2\" target=\"_blank\"> 
<img src=\"images/twitter.png\" border=\"0\" /></a>";} // Co Host Tiwtter 

if (isset($facebook2) && $facebook2) {echo " 
<a href=\"http://www.facebook.com/$facebook2\" target=\"_blank\"> 
<img src=\"images/facebook.png\" border=\"0\"/></a>"; } // Co Host Facebook 

if (isset($email2) && $email2) {echo "<a href=\"mailto:$email2\"> 
<img src=\"images/email.png\" border=\"0\" />";} // Co Host email 

echo "</div></div>"; //Closing of the Social Div and Column 3 

} else { // when the current dj is not in the system do the following 

echo "<div id=\"container\"><div id=\"column-1\"><div id=\"avatarpic\"> 
<img src=\"$djavatars/default.png\" /></div>"; 
    // Open Container, Column 1, and avatar pic. Display the default avatar 
echo "</div><div id=\"column-2\">"; // Close Column 1, Open Column 2 

echo "<div id=\"stats\"><div><strong><span>Now playing</span></strong></div>"; 
// Make the Div Stats and start showing data 

// if the song title is longer than 25 charaters then scroll the title 
if (strlen($artisttitle[1]) > 17) { echo " 
<div><marquee behavior=\"scroll\" scrollamount=\"1\" direction=\"left\" width=\"160\"> $artisttitle[1] </marquee></div><div><strong>By:</strong> $artisttitle[0]</div>"; 

} else if (strlen($artisttitle[1]) <= 17) {echo " 
<div>$artisttitle[1]</div><div><strong>By:</strong> $artisttitle[0]</div></div>";} 
//if the song title is less than 25 charaters then just display it as text 

echo "</div>"; } // Close Column 2 

} else {echo "<b><span style=\"color:#FFF;\">Trek Radio is currently experiencing 
<br />technical difficulties.<br /> Please check again later. (Error 100)</b> 
</span>";} // Error 100 connetion error to the DB 

} else {echo "<b><span style=\"color:#FFF;\">Trek Radio is currently experiencing 
<br />technical difficulties.<br /> Please check again later. (Error 200)</b> 
</scpan>";} // Error 200 connection error to shoutcast 
echo "</div>"; // Close Container 
?> 

現在,這個腳本應該給我當前歌曲的標題和DJ與目前的空氣。我沒有得到的是,當你去http://www.surayamedia.com/onair_tr/index2.phphttp://www.surayamedia.com/trdjs/index.php輸出是不同的。當它是相同的確切文件時,這怎麼可能?他們只是放在兩個不同的目錄!我不明白。我所要做的就是將腳本移動到服務器上的其他文件夾!

謝謝誰能找出解決這個問題的方法!

回答

0

這是一個服務器問題而不是代碼問題。

+0

上,請詳細說明問題的原因是什麼。某個時候,某人可能會從您在此提供的信息中受益。只寫「服務器問題」不太可能幫助其他人。 – andr

0

您已包含與腳本位於同一目錄中,因此它看起來像沒有顯示DJ缺少一個或兩個包含的那個。您可以將它們存儲在一個單獨的目錄中,而不是複製這些包含在公共html中的文件。

include ("config.php"); 
include ("header.php"); 

移入includes公共HTML以上:

include ("../../includes/config.php"); 
include ("../../includes/header.php"); 

如果包括存在於兩個目錄那麼就意味着有一些代碼在包括依賴於相對路徑。

+0

我明白你在這裏說什麼,但兩個目錄是相同的。他們將每個文件放在正確的位置,但它們只是顯示不同。 – Feek

+1

包含的東西依賴於相對路徑。您發佈的腳本不是問題,它所做的只是創建HTML,它是包含的。 – MrCode

+0

目錄/ onair_tr和/ trdjs是相同的我已經將所有文件從onair_tr複製到trdjs。唯一有相對路徑的是字體和滾動的js文件,正如你所看到的,它們都可以正常工作。 – Feek

相關問題