Hello,
I'm new to php and have just discovered the include function. I'm using php to include a few files on a page.
Although, the page does not display. I view the source and this is what is there.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
I try two different ways of coding my page, one completely php (using echo to show HTML) and the other one using html, with php to include the files (HTML <?php include() ?> HTML). However both have the same results.
This is the first code.
PHP Code:
<?php
include ('config.php');
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>';
include ($inc."css.php");
echo '<title>'.$title.'Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<div id="main">';
include ($inc.'header.php');
echo '<div id="body">
<div id="left">
<div class="title">
<h2>Left</h2>
</div>
<p>This is where the content for the left hand side would go, or posibally another menu...</p>
</div>
<div id="middle">
<div class="title">
<h2>Middle</h2>
</div>
<p>This is where the content for the middle part would go, this may be an introduction to the site or anything along the lines of that. </p>
</div>
<div id="right">
<div class="title">
<h2>Right</h2>
</div>
<p>This is where the content for the right hand side would go. </p>
</div>
</div>
</div>
</center>
</body>
</html>';
and this is the second code:
PHP Code:
<?php
include ('config.php'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<?php
include ($inc."css.php"); ?>
<title><?php echo $title ?>Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<center>
<div id="main">
<?php
include ($inc.'header.php'); ?>
<div id="body">
<div id="left">
<div class="title">
<h2>Left</h2>
</div>
<p>This is where the content for the left hand side would go, or posibally another menu...</p>
</div>
<div id="middle">
<div class="title">
<h2>Middle</h2>
</div>
<p>This is where the content for the middle part would go, this may be an introduction to the site or anything along the lines of that. </p>
</div>
<div id="right">
<div class="title">
<h2>Right</h2>
</div>
<p>This is where the content for the right hand side would go. </p>
</div>
</div>
</div>
</center>
</body>
</html>
config.php contains.
PHP Code:
<?php
// Main title
$title = 'S Gilligan :: ';
// Stylesheet URL
$css = "http://www.sgilligan.co.uk/css/style.css";
// URLS for menu
$home = "http://www.sgilligan.co.uk";
$tools = "http://www.sgilligan.co.uk/tools";
$downloads = "http://www.sgilligan.co.uk/downloads";
// Images
$mainlogo = "http://www.sgilligan.co.uk/images/mainlogo.png";
// Include main URL
$inc = "http://www.sgilligan.co.uk/includes/";
?>
includes/css.php contains
PHP Code:
<?php
echo '<link rel="stylesheet" type="text/css" href="http://www.sgilligan.co.uk/css/style.css">';
?>
and includes/header.php contains
PHP Code:
<?php
include ("./config.php");
echo '<div id="header">
<center>
<img src="'.$mainlogo.'" alt="S Gilligan.co.uk">
</center>';
include ($inc.'tabs.php');
echo '</div>';
?>
Sorry for the long post but its the only way I could get all the information across. I'd rather give too much info instead of too little.
Can someone help me to explain why this is happening.
Thanks in advance for any assistance.
Gilligan