include() doesn't work

Problems with the Linux version of XAMPP, questions, comments, and anything related.

include() doesn't work

Postby sydney_simon » 31. January 2007 02:29

Hello!
I hope that this is worthy of being a new topic, and not covered anywhere else.
I am new to linux but I have got XAMPP going (thank you). But my includes wont work!
they are relative paths - eg,
<?php
include "templates/head.php";
?>

I have tried and tried to change the value for "include_path" inside the etc/php.ini file: to things like ".", or "/opt/lampp/htdocs" etc - but to no avail.

It didn't work out of the box, so perhaps there is something obvious I haven't done? Perhaps I'm totally on the wrong track - any help appreciated, thanks - Simon
sydney_simon
 
Posts: 4
Joined: 31. January 2007 02:10

Postby Wiedmann » 31. January 2007 02:49

Code: Select all
<?php
include "templates/head.php";
?>

In which directory is this file?

Code: Select all
include "templates/head.php";

In which directory is the file "templates/head.php"?

I have tried and tried to change the value for "include_path"

What is the current value of "include_path" in the output from phpinfo().

But my includes wont work!

- error message in browser?
- Apache error_log?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby sydney_simon » 31. January 2007 05:28

Hello -

1) the value of path_include:
The value of path_include has been various things, as i have tried different combinations, but at the moment it is:
"/" on the phpinfo page.

2) where is the file containing the code "include 'templates/head.php'"?
The directory "template" is in the same directory as the document that contains the code:

Code: Select all
<?php
include "templates/head.php";
?>


when on this page I change the code from "templates/head.php", to being the whole path - something like "/opt/lampp/htdocs/simons/library/templates/head.php" - then it works -

in summary, the file is in the directory "library", the file i'm trying to include is in the directory "templates", which is in the directory called "library".
sydney_simon
 
Posts: 4
Joined: 31. January 2007 02:10

Postby Wiedmann » 31. January 2007 09:16

but at the moment it is: "/" on the phpinfo page.

That's not the XAMPP default. Please restore the original setting (and post this value).

when on this page I change the code from "templates/head.php", to being the whole path - something like "/opt/lampp/htdocs/simons/library/templates/head.php" - then it works -

Well then we can say:
The file containing the code "include 'templates/head.php'" is in the directory:
"/opt/lampp/htdocs/simons/library/

The file "templates/head.php" is in the directory:
"/opt/lampp/htdocs/simons/library/templates/"

You open the file, which containing the code "include 'templates/head.php'", in your browser with:
http://localhost/simons/library/file.php
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby sydney_simon » 01. February 2007 01:24

I haven't read the replies yet - thanks so much - Um,
I was running the website on a windows server and at some stage I must have made my directory have a capital first letter.

Paths are case sensitive in linux, of course. I've commented out the path_include line in the php.ini file, as the includes are working, fine without it.

Sorry about all that - this is my first linux experience -
Simon
sydney_simon
 
Posts: 4
Joined: 31. January 2007 02:10

Postby Wiedmann » 01. February 2007 01:35

as the includes are working, fine without it.

Fine :-)


BTW:
I must have made my directory have a capital first letter.

I don't see any "capital first letter" in your posts. It's really a good idea to give complete and correct infos if you ask for help. And not something like:
"to being the whole path - something like ..." <--
"But my includes wont work! they are relative paths - eg," <--

Only a hint for your next questions ;-)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby sydney_simon » 01. February 2007 01:39

I don't see any "capital first letter" in your posts. It's really a good idea to give complete and correct infos if you ask for help. And not something like:
"to being the whole path - something like ..." <--
"But my includes wont work! they are relative paths - eg," <--


Yes, you are absolutely right - my only excuse is that the pages are on my laptop at home and now i'm on my work computer at work... actually i'd better get to work - thanks again - Simon
sydney_simon
 
Posts: 4
Joined: 31. January 2007 02:10

Postby Wiedmann » 01. February 2007 01:49

actually i'd better get to work -

And I to bed :-) It's 1:45 am here.

BTW:
Don't work hard, work smart and have a nice day :-)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 50 guests