2010-02-28 14 views
0

他們都在我的XAMMP沙箱上正常工作,但現在什麼都沒有。我的包括似乎沒有工作,現在我已經上傳文件到生產服務器

我做錯了什麼。

下面是代碼:

的index.php

包含質量包括,基本上具有所有包括在其中。

<?php 

//Starting session 

session_start(); 

//Includes mass includes containing all the files needed to execute the full script 
//Also shows homepage elements without customs 

include ("includes/mass.php"); 

//Login Form 

$login = 


     "<form id='signin' action = 'login.php' method = 'POST'> 
     Username<input type= 'text' name= 'username'> 
     Password<input type= 'password' name= 'password'> 
     <input type= 'submit' value='login' name='submit'> 
     </form>"; 

//Calculate number of users online 

$num_users_sql = mysql_query("SELECT * FROM user WHERE loggedin = '1' ", $con); 

$num_online_users = mysql_num_rows($num_users_sql); 

//user bash link 

$user = "<a href='user.php'>User</a><br>"; 

//Register Form Link  

$registerlink = "<a id='signup' href='register.php'>Sign Up</a>"; 

//Logged In User Links 

$logoutlink = "<a id='logoutlink' href='logout.php'>Log out</a>"; 

$message = "<div id='welcome'>"."Hello"." ".$_SESSION['username']."!"."</div>"; 

$num_users_online = "<div id='users_online'><h2>There are ".$num_online_users." Users On Readnotes Right nw!</h2>"."</div>"; 

     if (isset($_SESSION['username'])) 

      //If user is logged in 

      { 

       echo $message; 

       echo $user; 

       echo "</br>"; 

       echo $num_users_online; 

       echo $logoutlink; 

      } 

     //If user is logged out 

     else 

      { 
       echo $login; 

       echo $registerlink; 

      } 


?> 

質量包括

包含了我所有的包括

<?php 

/*Mass include - mass.php* 
*Includes all thing needed for operations to start*/ 


//Grab Header design & details 

    require("header.html"); 

//Grab Footer design & details 

    require("footer.html"); 

//Grab include to connect to the database! 

    require("dbcon.php"); 


?> 

感謝名單。

+0

現在什麼?你的問題在哪裏? – Gumbo 2010-02-28 09:57:02

+0

問題是什麼 – Tapha 2010-02-28 10:01:47

+1

Gumbo的意思是:「什麼*它不起作用」*意思是說,在你的情況下? ;;你有什麼錯誤信息嗎? – 2010-02-28 10:02:59

回答

0

生產服務器的include_path中可能沒有.。要解決這個問題,請將其添加到包含內容中,例如./header.html

+0

我會給這個去 – Tapha 2010-02-28 10:33:05

1

的麻煩很常見的原因有關包括「不工作」時改變服務器:

  • 您developped在Windows計算機上,並在生產服務器是一臺Linux機器;;文件名和路徑在Linux上區分大小寫
    • 這意味着您應該檢查文件和目錄名稱中的小寫和大寫是否與您使用的文件和目錄名稱匹配。
  • 的另一個問題是文件沒有被發現...


關於第二個問題,兩個想法:

  • 使用require,而不是include;如果需求不起作用,您將收到致命錯誤
    • 並啓用error_reportingdisplay_errors,以查看錯誤消息。
  • 始終使用絕對路徑指向要包括的文件,並且從不相對那些
    • 當然,你不希望在代碼中鍵入蘭蔻pathes
    • 所以,你可以使用dirname功能,有點像這樣:


在您的文件 「主要」 (以及相同的想法應該被用於所有其他包括)

require dirname(__FILE__) . '/includes/mass.php'; 

注意dirname(__FILE__)將永遠給你你這個書面方式在文件是目錄的絕對路徑。


關於「允許錯誤報告和dislay」,因爲您可能根本無法訪問您的服務器的配置文件,最簡單的方法就是把這樣的事情在你的主腳本的頂部:

error_reporting(E_ALL); 
ini_set('display_errors', 'On'); 

因此,應該在瀏覽器中顯示錯誤 - 看看它們會比看看服務器的錯誤日誌更容易一些。

+0

現在試試這個, – Tapha 2010-02-28 10:29:10

相關問題