Support » How-To and Troubleshooting » PHP Include on Page

PHP Include on Page

  • Welp…I tried……

    First, I created a new page template…named it cams.php.
    and within the <div class=posts>
    I put:
    <?php include(‘cams/index.php’); ?>
    *cams/ directory is in the root directory of the website*

    Second, I created a page that used that template…and did not type anyting in the page text area….

    Third, I called the page….and well…..it gives me an fopen error when i know that the file exists because I can open up the directory and use the script fine. 🙁

    Please help.

    This is the script.


    and this is the page i’m using to include the script.


Viewing 9 replies - 1 through 9 (of 9 total)
  • The error is slightly misleading. It is not telling you that it cannot open cams/index.php. Rather, it’s telling you that it cannot open head.tpl as called within cams/index.php

    that’s what i mean…..i know that head.tpl is there….because i can see it when i look at the script directly.


    i just dont get it…..maybe it’s the way the index.php in the cams/ directory calls the head.tpl

    It’s very possible that the cams/index.php file is calling the head.tpl file, expecting it to be in the same directory as the calling application. In this instance, the calling application is actually one level above the cams directory.

    Perhaps the chdir() function might help?

    like this?


    // current directory
    echo getcwd() . “\n”;


    // current directory
    echo getcwd() . “\n”;


    it produces:

    /home/urbanweb/public_html /home/urbanweb/public_html/cam

    EH…wasnt using my noggin…lmao….figured out how to use it…

    the only thing with using “CHDIR” is that it wont use the “wrap-around” function….meaning, the links in the cams/ directory page….. IE. “Submit your cam” have to be hardcoded in the cam/ directory template AND because it’s hardcoded….it doesnt include the WordPress header like a REGULAR include would….

    would changing back to the original directory after the include help?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘PHP Include on Page’ is closed to new replies.