hello danifriends.
i'm developing my website with php and i want to make dynamic header, so i create i file header.php with logo and menu and the page had all html doctype and and head tag for link with css and js..., i include the header in my page using include(../header/header.php), and so i was thinking that i was going to have html doctype 2 time in every pages where i include header and the <head> so i delete the doctype in header.php and <head> after that i dont have any php error for include but the space of header when i include it is empty

I think it should be include ("../header/header.php");. Also, keep in mind that if you include it that way, you need to make sure that the path is correct.

You can also predefine the doctype and head tags in the current page and the load the contents of the inc.php files

thank you Aeonix but i my path is correct and i tried the both way still that space is empty.
thank you Gideon 1 for the reply i dont undestund what you mean with predefine the doctype, i must leave the doctype and the head tag on my header page ?? i'ts not problem ??

Hmmm, this may require direct access for faster solution. Would you mind installing TeamViewer and passing me the data through private message? It is a program that would grant me temporary access to your computer, in case you felt like I'm doing something I shouldn't be doing, you can easily shut the access down.

Because I can't think of anything extra from distance.

In case you'd rather not prefer to do this. Try touch("../header/test.txt); and look up if file appears next to header.php.

i'm sorry man i can't work with teamviewer cause i use production's server with my DB..., it was working fine until i delete html doctype and head tag in header.php or can someone tell is that problem if i let multiple html doctype and head tag on same pages ??

The question is what do you want to load with an include. A menu/navigation I can understand, so that you don't have to add a menu item on every page if you need to, but you say you want also what's in between the head tag in that include. Are you planning to change dynamically the meta data, title tag, stylesheets, etc. for every page then?

i have two pages one is header.php for my menu with html doctype and head tag, and i include it in my index page, my index page has also html doctype and head tag, when i include header into index it was working fine, and just i find it not good idea to have doctype in header.php and the head tag , when i delete the html doctype and head tag in header in the index the header space where i call include is empty.

header.php should only contain the code/mark-up that is for your menu, Thus no doctype, no head, no html and no body tags, just only the relvant code/mark-up for you menu. Do you have it like that?

oh thank you friends and i realy apologyse for late reply i had exam last week, and i couldn't be up here.
so according to last last reply of gentlemedia i'm going to check my code maybe the error is in a php somewhere and not thats tags, anyways friends i will kepp you up to date if i solve my problem

To give you an example what should only be in header.php if you want to include your menu/navigation on all your pages.

<nav role="navigation">
    <a href="home.php"><img src="img/logo.svg" alt="logo" /></a>
    <ul>
        <li><a href="home.php">home</a></li>
        <li><a href="portfolio.php">portfolio</a></li>
        <li><a href="services.php">services</a></li>
        <li><a href="contact.php">contact</a></li>
    </ul>
</nav>

You see? no html, no head and no body tags... just the mark-up for your menu.

This can then be included into your header for example like this:

<!doctype html>
<html>

<head>

<!-- All your meta data & stylesheets in here -->

</head>

<body>

    <header>

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

    </header>

    <main role="main">

        <!-- main content -->

    </main>

    <footer>

        <!-- footer content -->

    </footer>

</body>

</html>

This is the complete process

index.html

<html>
<body>

<?php
include("header.php"); // include header content
?>
Welcome To The Candy Shop <br>
<?php
include("footer.php"); // include footer content
?>

</body>
</html>

header.php

<!-- Header Content -->

<a href="index.php">Home</a> |
<a href="products.php">Products</a> |
<a href="aboutUs.php">About Us</a> |
<a href="contactUs.php">Contact Us</a> |<br>

<!-- End Header Content -->

footer.php

<!-- Footer Content -->

Copyright © 2010 TheCandyShop.com

<!-- End Footer Content -->

i did same

 <?php include('../header/header.php'); ?> /* IN INDEX.PHP */



//HEADER CONTENT 
<header class="header">
            <a href="#" class="header__icon" id="header__icon" onClick="fonctionmrnu.js"></a>
            <nav class="menu">
                <?php do { ?>
                <a href="#"><?php echo $row_principmenu['categorie']; ?></a>
                  <?php } while ($row_principmenu = mysql_fetch_assoc($principmenu)); ?>
            </nav>
        </header>

unless in header.php before <header> tag i have code for DB here is the whole page code

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_principmenu = 10;
$pageNum_principmenu = 0;
if (isset($_GET['pageNum_principmenu'])) {
  $pageNum_principmenu = $_GET['pageNum_principmenu'];
}
$startRow_principmenu = $pageNum_principmenu * $maxRows_principmenu;

mysql_select_db($database_agdb, $agdb);
$query_principmenu = "SELECT * FROM apcategorie ORDER BY id ASC";
$query_limit_principmenu = sprintf("%s LIMIT %d, %d", $query_principmenu, $startRow_principmenu, $maxRows_principmenu);
$principmenu = mysql_query($query_limit_principmenu, $agdb) or die(mysql_error());
$row_principmenu = mysql_fetch_assoc($principmenu);

if (isset($_GET['totalRows_principmenu'])) {
  $totalRows_principmenu = $_GET['totalRows_principmenu'];
} else {
  $all_principmenu = mysql_query($query_principmenu);
  $totalRows_principmenu = mysql_num_rows($all_principmenu);
}
$totalPages_principmenu = ceil($totalRows_principmenu/$maxRows_principmenu)-1;
?>
        <link href='http://fonts.googleapis.com/css?family=Roboto:500,400' rel='stylesheet' type='text/css'>
        <link href="../style/bodystyle.css" rel="stylesheet" type="text/css">
        <link href="header.css" rel="stylesheet" type="text/css">
        <link href="menuresponsive.css" rel="stylesheet" type="text/css">
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>
        <script type="text/javascript" src="../js/jquery-1.11.3.js"></script>
        <script type="text/javascript" src="fonctionmenu.js"></script>
  <header class="header">
            <a href="#" class="header__icon" id="header__icon" onClick="fonctionmrnu.js"></a>
            <nav class="menu">
                <?php do { ?>
                <a href="#"><?php echo $row_principmenu['categorie']; ?></a>
                  <?php } while ($row_principmenu = mysql_fetch_assoc($principmenu)); ?>
            </nav>
        </header>
  <?php
mysql_free_result($principmenu);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.