Results 1 to 3 of 3

Thread: include_once not working

  1. #1
    Join Date
    Mar 2013
    Beans
    2

    Question include_once not working

    Hello all,
    I have performed a LAMP installation.
    All working right, except include function in PHP.

    On index.php i have 2 include:
    include_once "../config.php";
    include_once "../header.php";

    When i open this page nothing is included.

    Any suggestion to solve?

    TKS

  2. #2
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,590
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: include_once not working

    See if any errors are logged in /var/log/apache2/error.log. You'll need to have root privileges via sudo to see this file. As a guess ../config.php probably isn't in the location you think it is. Try using full paths.

    Code:
    include_once "/path/to/config.php";
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Feb 2008
    Beans
    251
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: include_once not working

    Hey,

    Just to add to SeijiSensei's answer above, your script is looking for the files in the parent directory of the index.php file ... that's what the "../" means at the beginning of the file path.

    So if your index.php file is here: /var/www/site/index.php then it will be looking for the two files here:
    • /var/www/header.php
    • /var/www/config.php

    and I guess it's not finding them there.

    Good luck!
    Gp

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •