/    Sign up×
Community /Pin to ProfileBookmark

PHP Include not parsed when page is opened from link

Hi,
I’m having problems using the php include statement.
When I open the web page with the php include directly the included file is parsed, and when I view page source I see the content of the included file.
When I open the same page through a link the php include does not get parsed and in view source I see only the php include statements.

Here’s part of the code.

header.php

[CODE]<div id=”header” style=”width: 100%; height: 130px;”>
<img src=”images/dove_logo10.png” alt=”reiki for peace logo” style=”float: right; margin-top: 0.5em; margin-right:2.5em;”></img>
</div>
[/CODE]

webpage with header.php included.

[code=html]<html>
<body>
<div id=”screenWrapper”>

<?php include (“include/header.php”); ?>

<div id=”mainContDiv” >
<p> Bla Bla </p>
</div>
</div>
<?php include(“include/footer.php”); ?>
</body>
</html>
[/code]

I’m using xampp for windows.
I’m sure the solution is very simple, but this problem has already consumed a good few days of my life so any help much appreciated.

Thanks

David

Paddling upstream searching for the source

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscJun 14.2011 — As a side note, your img tag is incorrect in header.php - it's a singleton tag and the </img> isn't valid.

Onto your post, does the link use http://localhost or does it just point to something like file:///.....yourdoc.php

It needs to be served via your server (i.e. through localhost) to be parsed.
Copy linkTweet thisAlerts:
@davidM_MEauthorJun 14.2011 — Hi aj_nsc thanks for the reply

This is the link from the menu (included from menu.php)

[code=html]

<li class="accordionButton"><a class="rfpMenuBtn" href="rfp_eng_whatisreiki.php">What is Reiki ?</a></li>
[/code]


and this is what I entered in httpd-vhosts.conf for the site

[CODE]<VirtualHost www.reikiforpeace.local>
DocumentRoot "D:reikiforpeacephp_website"
ServerName www.reikiforpeace.local

CustomLog

"D:reikiforpeacephp_websitelogswww.reikiforpeace.local.access.log"

combined
ErrorLog "D:reikiforpeacephp_websitelogswww.reikiforpeace.local.error.log"

<Directory "D:reikiforpeacephp_website">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
[/CODE]


As I said when I use the link he doesn't recognize the <?php include tag so I only see what's not in the include files, when I open it directly it's recognized, parsed and everything appears as intended.

David
Copy linkTweet thisAlerts:
@aj_nscJun 14.2011 — Interesting....mind if I ask what the URL in the address bar is when you open it directly, vs when you click on the link?
Copy linkTweet thisAlerts:
@davidM_MEauthorJun 14.2011 — Interesting question.

I'm using HTML-Kit build 292 with the php plugin to develop the site.

When I preview the page directly the address bar contains:

file:///D:/ReikiForPeace/php_website/[B]TMP9A.HTM[/B]


When I link to the page the address bar contains:

file:///D:/ReikiForPeace/php_website/rfp_eng_whatisreiki.php

Therein lies the answer me thinks?

Please put me out of my misery
Copy linkTweet thisAlerts:
@aj_nscJun 14.2011 — Wow....this is a new one to me. I've got an idea, though, from the clues you've provided.

You said you're using an HTML-Kit plugin.....maybe it only parse .htm(l) pages.....what if you change the extension of your php file to .htm?

Other than that, I have no idea, I usually deal with PHP on a server and really have no idea what to do with HTML Kit
Copy linkTweet thisAlerts:
@NogDogJun 14.2011 — I've always found it easier to just open a browser window and test by entering the "http://localhost/file_name.php" URL when testing -- assuming you have a web server/PHP installed locally. Then you don't have to worry about whether or not your IDE/editor is opening the file via the web server in order to process it as PHP. (I haven't used HTMLKit in years, so don't know about any PHP plug-ins.)
Copy linkTweet thisAlerts:
@davidM_MEauthorJun 14.2011 — Your questions and suggestions got me thinking that the problem wasn't with my coding but with the xampp php html-kit setup on my machine so I moved the web site to xampphtdocs which I understand is the localhost, and guess what everything now works ok. I didn't solve the problem, but I solved my problem. Thanks for leading me to the solution.
×

Success!

Help @davidM_ME spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...