include file!!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

php-punk
New php-forum User
New php-forum User
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk
Contact:

include file!!

Postby php-punk » Tue Jul 15, 2003 1:29 pm

i have made a website with PHP using a mysql backend, and using include files for the header, trouble is on some pages i get an error saying it cant include other it works fine:

Error Msg: Warning: Failed opening '/includes/layout_top.inc.php' for inclusion (include_path='.:/usr/share/pear') in /home/vhosts/punk-style.to-j.com/index.php on line 19

CODE:
It doesn't work here:(root dir)

Code: Select all

</head>

<body>
<? include("/includes/layout_top.inc.php"); ?> 
 


but works here (1st sub dir)

Code: Select all

<? include("../includes/layout_top.inc.php"); ?>
anyone got n e ideas?

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Tue Jul 15, 2003 10:48 pm

with a ../ it means go back one directory and then go into this directory.

Your includes folder must be on the same level as your root folder, where the includes folder should be a sub dir to your root.

php-punk
New php-forum User
New php-forum User
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk
Contact:

Postby php-punk » Wed Jul 16, 2003 12:40 am

the include directory is a sub dir of root

the first set of code is exectued form the root, and doesn't use '../' the 2nd piece of code is within a sub dir of root and DOES use '../'

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Wed Jul 16, 2003 2:03 am

I just saw your simple solution.

instead of including "/include/whatever.inc" try including "include/whatever.inc".

Sorry, I didn't see that before.


Return to “PHP coding => General”

Who is online

Users browsing this forum: buckibooster and 5 guests