Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 06:08PM

I've installed wampserver 2.2 on my windows 7 tower and windows xp laptop.
the following code works:
(Index.php)
<?php include("menu.php"winking smiley; ?>
<p>This is my home page that uses a common menu to save me time when I add
new pages to my website!</p>
</body>
</html>
(menu.php)
<html>
<body>
<a href="[www.example.com]; -
<a href="[www.example.com] Us</a> -
<a href="[www.example.com]; -
<a href="[www.example.com] Us</a> <br />

the following does not:
<html>
<?php include("head.inc"winking smiley; ?>
<body>
<?php include("boxbanner.inc"winking smiley; ?>
<div id="all">

<div id="leftbit">
<ul>
<li><a href="genealogy/grpmain.php">Family Group Sheets</a></li>
<li><a href="forward.php">WWvA Letters</a></li>
<li><a href="valinks.php">Civil War Links</a></li>
<li><a href="vacontact.php">Contact Information</a></li>
... followed of course by the rest of the html

Wampserver is green, all process started, phpmyadmin works, phpinfo works.

it does not work though when I create a file
(phpi.php)
<?php
phpinfo()
?>
and enter "localhost/phpi.php" in a browser. It just gives me a blank screen. View source shows me unprocessed php code.

The extensions for the OS are shown ( so I'm not looking at phpi.php.txt ) that's one of the first things I do when I load an os.

All day yesterday and 3 hours today - would someone please tell me what I'm doing that so blasted dumb!
//al

Preview here shows a smiley face - obviously those are a close parenthesis followed by a semi-colon.

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 06:10PM

quick followup, though I don't see pertinence.
the test code menu are locate in c:\wamp\www\test
my code is located in c:\wamp\www\aljonesus

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: August 21, 2012 06:26PM

If you include a file without a .php extension it will not run the php code in that file.
<?php
include( "xxx.inc" ); // does not work if the content is php

include ( "xyz.inc.php" );   // does work

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 06:49PM

RiggsFolly,
Not true, looking at the examples on [php.net] they have examples where they're including files that have non-php extensions.
Also, changing the sample "menu.php" file above to "menu.inc" and the include line, it still functions as intended.
Changing the .inc in my file to php still does not process the php but returns it in the html - which is then ignored.

It appears as if php is completely ignoring the fact that my files include php code with a php extension and is just passing on the php code o the output.

I really wish it were something that simple. I'm just getting started with php and have no problem saying I'm ignorant!

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: stevenmartin99 (Moderator)
Date: August 21, 2012 06:55PM

grab teamviewer and ill take a look

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: August 21, 2012 06:56PM

Yea sorry you are right. my mistake.

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 06:58PM

Steve, give me a minute or two.

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: stevenmartin99 (Moderator)
Date: August 21, 2012 07:05PM


Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 07:08PM

Info in PM to you, at your convenience, sir.

Options: ReplyQuote
Re: Newbie: Include in my code not working
Posted by: aljones (---.bigbend.net)
Date: August 21, 2012 08:23PM

To follow up for others information.
I had attempted, at one time, to do some server side includes. I decided that the potential to do more, better would come from using php. What I had forgotten was that I had modified my .htaccess file.
Steve helpfully pointed that out - after wandering round a little.
Problem solved, and you have my unconfused appreciation, sir!
//al

Options: ReplyQuote


Sorry, only registered users may post in this forum.