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条)

报告相同问题?

悬赏问题

  • ¥15 cplex运行后参数报错是为什么
  • ¥15 之前不小心删了pycharm的文件,后面重新安装之后软件打不开了
  • ¥15 vue3获取动态宽度,刷新后动态宽度值为0
  • ¥15 升腾威讯云桌面V2.0.0摄像头问题
  • ¥15 关于Python的会计设计
  • ¥15 聚类分析 设计k-均值算法分类器,对一组二维模式向量进行分类。
  • ¥15 stm32c8t6工程,使用hal库
  • ¥15 找能接spark如图片的,可议价
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 博通raid 的写入速度很高也很低