Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: can't get includes to load Date: Tue, 26 Mar 2013 09:36:06 +0100 Lines: 64 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net rStdvEnnwyuYS9FD/rWHmwHcqA94pcghaCm4x77P3pMpQVXJvP Cancel-Lock: sha1:NIM/ABH69kxD7xIzt0xVcPZi9RM= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130315 Thunderbird/17.0.4 In-Reply-To: Xref: csiph.com comp.lang.php:8857 On 26/03/13 07:52, Cal Dershowitz wrote: > $ pwd > /home/sites/migrate > $ ls -l > total 168 > ... > drwxr-xr-x 2 fred automation 4096 Mar 25 23:03 includes > -rw-r--r-- 1 fred automation 2208 Mar 25 23:32 index.html > ... > -rw-r--r-- 1 fred automation 896 Mar 25 21:49 style.css > ... > drwxr-xr-x 2 fred automation 4096 Mar 25 21:56 variables > $ cd includes/ > $ ls -l > total 20 > -rw-r--r-- 1 fred automation 88 Mar 25 23:03 footer.php > -rw-r--r-- 1 fred automation 106 Mar 25 23:02 footer.php~ > -rw-r--r-- 1 fred automation 99 Mar 25 22:08 header.php > -rw-r--r-- 1 fred automation 0 Mar 25 21:57 header.php~ > -rw-r--r-- 1 fred automation 141 Mar 25 22:15 nav.php > -rw-r--r-- 1 fred automation 0 Mar 25 21:59 nav.php~ > -rw-r--r-- 1 fred automation 638 Mar 25 22:16 sidebar.php > -rw-r--r-- 1 fred automation 0 Mar 25 22:00 sidebar.php~ > $ cd .. > $ cat index.html > > > > From the file layout, it looks correct, we do recommend you use $_SERVER['DOCUMENT_ROOT'] for includes eg: include $_SERVER['DOCUMENT_ROOT'].'includes/sidebar.php'; this will make it easier the day when you put things in sub folders, like /home/sites/migrate/articles and you still want to include those from /home/sites/migrate/include. > Right now, index.html loads but none of the other and it exits without > complaint. This is only running on my linux machine here at the local > root directory, which is indicated by the pwd command. You have an index.html, when apache looks at the file it will think of it as plain html and just output it as it is, you can easily verify this by looking at the source code in the browser (right click on the page and select "View Page Source"), you will see those tags. The fix is to do a: mv /home/sites/migrate/index.html /home/sites/migrate/index.php now apache will use the php engine to parse the file and php engine will replace the with the content in the files. Sure there are some people who would say to add html to the AddHandler for php, but please do not listen to them, you will make your apache/php to work more and you will not be compliant with most hosting companies, so when you upload your things to your web hotel you want it to work. -- //Aho