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 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据