2010-02-28 16 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

相关问题