doutangguan2460 2012-08-08 16:11
浏览 118
已采纳

require_once函数导致服务器错误

I am trying to use the require_once(""); function in php, and it is causing a server error whenever it is used. I know I am using the correct path because I have checked my file directory many times and have been following a video tutorial as well when coding this php code. Any ideas to why I am getting this server error?

       <?php
            require_once("../../includes/session.php");
       ?>

The page calling this function is in a folder that shares folders - two sub-folders away from session.php if that makes sense.

This file is index.php, which is in public/admin. This page calling require_once is in public/admin/index.php, and the folder they both share is photo_gallery.

The error is: HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

All the debugging I have done is echo a hello statement before calling require_once and after require_once and when I posted hello after nothing was outputted

This is the error I receive when checking my error log:

[08-Aug-2012 11:01:04] PHP Parse error: syntax error, unexpected '{' in /home3/visittom/public_html/photo_gallery/includes/session.php on line 47

  • 写回答

3条回答 默认 最新

  • douduan5086 2012-08-08 16:17
    关注

    require and include paths are relative to the file where they are declared, not necessarily the page that is loaded by the user. So if your index.php includes another page which contains the require_once you may run into problems.

    Also, check the web server error logs which should provide more detail about that 500 error.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路