Web Design Forum: My php include is not working - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

My php include is not working

#1 User is offline   gigman7 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 64
  • Joined: 31-August 11
  • Reputation: 0

Posted 09 November 2011 - 10:57 PM

I have installed LAMP and have started working on my web site. For some reason, my include isn't working. Here is what I have.

<?php

$title="Study Question | Your Study Buddy";
$currentpage="includes/pages/index.php";
include "includes/page.php";

?>


It will include a file if it is in the same folder. Why is it not included here?

This post has been edited by Renaissance-Design: 03 December 2011 - 12:00 PM
Reason for edit: Please use the code button or tags to format your code.

0

#2 User is online   mrchristoph 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,359
  • Joined: 18-August 09
  • Reputation: 93

Posted 09 November 2011 - 11:37 PM

is it in a sub folder like the variable above? include "includes/pages/page.php";

Code looks alright, so must be a path problem.
0

#3 User is offline   Nitin Reddy 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 55
  • Joined: 11-September 09
  • Reputation: 6
  • Gender:Male
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 02 January 2012 - 02:50 AM

View Postgigman7, on 09 November 2011 - 10:57 PM, said:

my include isn't working.
<?php
$title="Study Question | Your Study Buddy";
$currentpage="includes/pages/index.php";
include "includes/page.php";
?>



Assuming that the page you are on is located at "includes/pages/index.php" and you want to include the page at "includes/page.php", what you need to do is type in:
include '../page.php';


Typically, you would include a file that is within a child folder rather than a file that is in a parent folder, but the approach has been used to include configuration settings. WordPress supports configuration files that are located in a parent folder too (move the configuration file to a folder up in the hierarchy and check it out!).
0

#4 User is offline   sclarke 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 27
  • Joined: 03-January 12
  • Reputation: 1
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 11 January 2012 - 02:35 PM

View Postgigman7, on 09 November 2011 - 10:57 PM, said:

I have installed LAMP and have started working on my web site. For some reason, my include isn't working. Here is what I have.

<?php

$title="Study Question | Your Study Buddy";
$currentpage="includes/pages/index.php";
include "includes/page.php";

?>


It will include a file if it is in the same folder. Why is it not included here?

Try using a relative, so

<?php

$title="Study Question | Your Study Buddy";
$currentpage="includes/pages/index.php";
include "./includes/page.php";

?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users