0

I have four pages that I am trying to condense and make easier to maintain. I plan to use PHP to create the "web parts" for the common parts of each page. The problem is that the header.php page loads and displays everthing it should, but the html files will not load the php page when i use . I have used the developer tool and have no more errors, what else would cause this problem? I have used include and require changed single quotes to double and everything I could read of or think about. I will only paste one HTML page and my PHP page.

I am using QuickPHP for my server functions

HTML:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
   <link rel="stylesheet" type="text/css" href="styles.css">
   <script type="text/javascript" src= "clock.js"></script>
   <script type="text/javascript" src= "links.js"></script>
   <meta charset = "utf-8" />
        <title>
      CSE Center for Health Information Technology
    </title>
</head>

<body onload="time()">

<?php require'header.php'; ?>

    <div class = "content">
    <p> 
    <ul>
    <strong>
        <div class = "color">Lastest News!</div> 
    </strong>
    <li> New Positions open at CHIT, click above link to see if you qualify!
 </li>
    <li> New hospital being built in Canton, GA. </li>

<li> CHIT signed agreement with Federal Government to be initiate country wide review
</li>
    </ul>
    </p>

    <p>
    <strong>
        General Information about the Center for Health Information Technology:
    </strong>
    <br />

CHIT was formed to provide certification and compliance  
testing services both to organizations that build and market HIT systems,
and to healthcare providers and hospitals who have implemented HIT systems.
    <br />

Conduct research into the issues that healthcare providers and hospitals face 
in selecting, implementing, and integrating HIT systems.
    <br />

Conduct research and develop tools to strengthen the privacy and security 
of health information, and help people understand their rights and the  resources
available to safeguard their personal health data.

<!-- All three of these came start from http://cse.spsu.edu/chit/index.shtml -->
    <br />
    </p>
    </div>
    <p>
        <h2>Current Time</h2>
        <h2 id="currenttime">now</h2>
    </p>
</body>
</html>

PHP:

<div class = "header">
    <p>
    <a href="http://www.spsu.edu">
<img src="    http://spsu.edu/_resources/images/img_index_logo.png"
    alt="SPSU Home" width="263" height="119" border="0"/></a>
    <br />
    <a href="http://cse.spsu.edu"> SPSU's CSE Home Page <br /> </a>
    </p>

    <p>
    <h1>
        Welcome to the Center for Health Information Technology
    </h1>
    </p>

    <div id="pagelinks">
    <p>
    <strong>
        Page Links!
    </strong>
    <br />
        <select name="links" id="pagelink" onchange="linkchange()">
        <option value = "" >Other Pages</option>
        <option value = "index.html" >Home</option>
        <option value = "faculty.html" >Faculty</option>
        <option value= "survey.html" >Survey</option>
        <option value= "positions.html" >Jobs</option>
        </select>
    </p>
    </div>
</div>
2
  • to use php, your extension must be *.php Commented Sep 26, 2013 at 14:43
  • The only thing I can see what's wrong with your header.php is you nesting a h1 in a p. Both may only accept inline elements and both are block elements. Commented Sep 26, 2013 at 14:44

2 Answers 2

1

The server sends your code right to the browser because it sees the .html extension. If it were a .php extension, the server would know how to handle the php code inside. Take a look at this explanation. http://php.about.com/od/advancedphp/p/html_php.htm

Sign up to request clarification or add additional context in comments.

4 Comments

Note that the link mentions a way to change your .htaccess file in case your .html file is an established file. <Files yourpage.html> AddType application/x-httpd-php .html </Files>
these are local HTML files and the "server" I am using is "QuickPHP" as far as I know, I do not even have a .htaccess file. If I changed my HTML files to PHP files would I have to make all the double quote's " into single quotes '?
The .htaccess file is an invisible file (the dot before the filename indicates this). I'm not sure how you're accessing your files, but you can go into your admin panel of your hosting server and see the invisible file that way. If there isn't one, one can easily be created by putting in the desired content and saving it as .htaccess (this is the exact filename, not .htaccess.txt or whatever. JUST .htaccess)
If you have a lot of .html files, it's a waste of time to change them all to .php. Also, if this site of yours is already out in the real world, changing to .php extensions will break the inbound links from other sites. I'm not sure what you mean by "...would I have to make all the double quotes into single quotes..."
0

The HTML file should also be a PHP file because your HTML file contains PHP code segment which cannot be parsed by the server if not provided with a .PHP file extension. I expect your problem will be solved.

Whatever developer tool you use will not state any error in the PHP code segment- <?php require'header.php'; ?> because it will be considered as a tag and nothing more. Hope this will help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.