Problem w/ PHP include

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

Problem w/ PHP include

Postby CasualCache » 07. June 2013 21:41

Hi,
i'm a XAMPP newbie and have a problem using the PHP-Command include.
I want to include this file:
Code: Select all
<header>
    <h1>My Pages.</h1>
  </header>
  <div id="sidebar">
    <div id="sidesec">
      The Sidebar of Doom!
      <br>
      -------------------------
      <br>
   <span id="sideitem"><a href="#">Home</a></span>
   <br>
   <span id="sideitem"><a href="#">About me.</a></span>
    </div>
    <div id="sidesec">
      Lorem Ipsum
      <br>
      dolor sit amet,
    </div>
  </div>

into this file:
Code: Select all
<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width" />
  <title>About me.</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>

<?php include(http://localhost/test/Skeleton.php); ?>   
   
<div id="main">
      <div id="post1" margin-top="5px">
              <div id="ut">
        <h2>Lorem Ipsum</h2>
        Dolor sit amet.
      </div>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tincidunt sodales tellus et condimentum. Vestibulum ac magna ac enim venenatis porttitor vel a lorem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi placerat massa fermentum justo tempor in rutrum erat tempor. Phasellus tempus rhoncus odio, id mattis ipsum viverra id. Fusce in lectus vel dolor interdum laoreet. In ut mi velit.
      </div>
    </div>
   </div>
</body>
</html>

but it doesn't seem to work (i.e. the content of the .php file is not displayed.).
When I use the Firefox Debugger to check the code the include command turned into this:
Code: Select all
<!--?php include(http://localhost/test/Skeleton.php); ?-->
.
Why could this be happening? XAMPP is installed (I see the orange index page) and php is up and running.
Thanks in advance,
CasualCache
CasualCache
 
Posts: 3
Joined: 07. June 2013 21:26
XAMPP Version: 5.6.3
Operating System: WinXP

Re: Problem w/ PHP include

Postby Altrea » 07. June 2013 22:02

Hi CasualCache,

What is the address your Browsers address bar is showing at the time you "open" the file?

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby CasualCache » 07. June 2013 22:03

localhost/test/aboutme.html
CasualCache
 
Posts: 3
Joined: 07. June 2013 21:26
XAMPP Version: 5.6.3
Operating System: WinXP

Re: Problem w/ PHP include

Postby Altrea » 07. June 2013 22:04

PHP in .html files don't get parsed through the php interpreter.
Change the file extension to .php
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby CasualCache » 07. June 2013 22:07

No, wait, the file I am including into has the localhost/test/aboutme.html location. And there, instead of simply showing
Code: Select all
<?php include(http://localhost/test/Skeleton.php); ?>
it comments it out when opened in Firefox. The file being included has the location localhost/test/Skeleton.php
CasualCache
 
Posts: 3
Joined: 07. June 2013 21:26
XAMPP Version: 5.6.3
Operating System: WinXP

Re: Problem w/ PHP include

Postby Altrea » 07. June 2013 22:15

The file you request with your browser at the end needs to have the .php file extension.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include Please help.

Postby MrMyckster » 22. June 2013 10:21

I am having the same problem using a php include on an htm or html page on the Xampp server. So after I saw this thread I knew I was not the only one. Please help out a person new to this board.

I know you can do it because I am doing it on my internet host site.

The host company changed the .htaccess file to add the handler as shown:

addhandler x-httpd-php5-cgi .php5
addhandler x-httpd-php-cgi .php4
Options +ExecCGI
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
AddType text/html .htm .html .php
AddOutputFilter INCLUDES .htm .html .php

However when I change my .htaccess file in XAMPP in the directory I am working on, it will still not parse the php in the html file.
It is a legacy system and it has 100,000 files so there is no way to change all the files to php extensions. The file is an .html file but I have .htm files as well.

I got information that I may have to change the XAMPP php.ini file from the Dreamweaver forum. However I am not sure that is the right answer or what to change to make it work.


I am running XAMPP 3.1.0 on Windows 7 using Dreamweaver to program the pages. This is my first installation of XAMPP using php for a testing server so I hope I have given you (everyone) enough information to help me out.
MrMyckster
 
Posts: 5
Joined: 22. June 2013 09:57
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem w/ PHP include

Postby Altrea » 22. June 2013 11:33

sending static files (.htm, .html, .css, images, etc) through the php parser is a big concept failure. But if you really want to do it, do it like so:

  • open the file \xampp\apache\conf\extra\httpd-xampp.conf
  • ~ line 20 is that line
    Code: Select all
    <FilesMatch "\.php$">
  • replace it with
    Code: Select all
    <FilesMatch "\.(php|html|htm)$">
  • save the file
  • restart Apache
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby MrMyckster » 22. June 2013 18:29

Thank you for the reply. I did what you said to do, however it didn't completely fix the problem. Is there other areas that I need to do that to as well?
MrMyckster
 
Posts: 5
Joined: 22. June 2013 09:57
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem w/ PHP include

Postby Altrea » 22. June 2013 18:34

No. Maybe you have other problems, but without any knowledge about the issue and the code parts we can't help you.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby MrMyckster » 23. June 2013 03:19

I am not sure what you mean "other problems".

I made the changes you suggested. I opened up the index.htm file in Dreamweaver, The links show as broken, I tried to view the file in the web browser and it wants me to open a file to download.

The same file, saved as index.php shows the live code and opens up when I use the browser to view the file.

Anyone else have any advice?

Thank You.
MrMyckster
 
Posts: 5
Joined: 22. June 2013 09:57
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem w/ PHP include

Postby Altrea » 23. June 2013 07:43

Testcase:

I made the single line change in the httpd-xampp.conf i posted here
I started Apache.

I have the following files:

\htmlparsing\index.htm
Code: Select all
<?php
echo 'parsed .htm file<br>';
include __DIR__.'/include.php';


\htmlparsing\include.php
Code: Select all
<?php
echo 'included successful';


I request http://localhost/htmlparsing/index.htm
I get the expected result. The echo from the index.htm as well from the included file is shown in the browser.

How should i help you now? I don't know your code.
You said php parsing in .htm/.html files is your problem and that change solves that issue.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby MrMyckster » 24. June 2013 01:08

Alright. I created the directory htmlparsing and put that in the htdocs folder inside the xampp directory. I created the files like you suggested and I got that to work.

parsed .htm file
included successful

http://localhost/xampp/phpinfo.php works fine and returns values.

Keep in mind, I am not trying to be difficult. This is my first Xampp installation to set up as a testing server for Dreamweaver. The parsing of the .htm and .html with the php may have only been a symptom of another problem.

Maybe this is the best answer I can get. The Dreamweaver people (Their support board) told me it was an Xampp set up problem and you have proved that it can parse the .htm with the include. I just don't understand why Dreamweaver still shows the links as broken, and when you try to open them in the browser it opens a window that offers you to download a file.

So what is the next step that you suggest I try?
MrMyckster
 
Posts: 5
Joined: 22. June 2013 09:57
XAMPP Version: 5.6.3
Operating System: Windows 7

Re: Problem w/ PHP include

Postby Altrea » 24. June 2013 04:52

IMHO this is one of the many Dreamweaver configuration problems reported here at the board.
DWs configuration is far away from being self speaking especially for beginners.
But we can't provide any support for Dreamweaver here (or any other IDE).
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6762
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Problem w/ PHP include

Postby MrMyckster » 25. June 2013 09:45

I understand you cannot provide support for another manufactures product.
I think you did just about all you can do for me and I thank you.
MrMyckster
 
Posts: 5
Joined: 22. June 2013 09:57
XAMPP Version: 5.6.3
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 49 guests