相同的php文件但在不同的文件夹中显示不同的输出

时间:2012-12-17 07:30:32

标签: php mysql

我真的很奇怪。我有一个单独的php文件,我称之为index2.php(我将给出下面的代码)我在两个不同的目录中有这个文件,当我加载然后在我的Web浏览器中我得到两个不同的输出。有人可以告诉我这是怎么可能的!?

 <?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时,输出会有所不同。当它是完全相同的文件时,它怎么样?它们只是放在两个不同的目录中!我不明白。我要做的就是将脚本移动到服务器上的另一个文件夹中!

感谢您有谁能够解决可以采取哪些措施来解决这个问题!

2 个答案:

答案 0 :(得分:0)

您有与脚本位于同一目录中的包含,因此看起来不显示DJ的包含一个或两个包含。您可以将它们存储在单独的目录中,而不是复制包含,可能在公共html之上。

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

进入公共html上方的includes

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

如果包含在两个目录中,则表示包含中的某些代码依赖于相对路径。

答案 1 :(得分:0)

这是服务器问题,而不是代码问题。