Jump to content

[SOLVED] proper way to include a file?


simon551

Recommended Posts

Hi, I can't understand why this markup is making my page stop functioning. If I take it out, my javascript will fire, but if I leave it in, nothing.

 

</div>
<div id="menu">
	<?php require_once('../includes/NewMenu.inc.php'); ?>
</div>

 

I don't know for sure this is a javascript or html or php problem... posting here because if I take out the <?php require_once()?> and just leave an empty <div></div> then my page works fine.

 

I'm using dreamweaver which also tells me this is an overlapping or unenclosed tag. but eh?

Link to comment
Share on other sites

*chuckles at dw*

 

Anyhow the inc.php is not causing the problem the way it is setup is fine and works because the naming scheme lets you know what the file is. Leave that be.

 

Instead post the code for NewMenu.inc.php and maybe even view the source of the page see if there are any errors being hidden.

Link to comment
Share on other sites

The menu:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<!--//the functionality for the drop-down was provided here: http://www.alistapart.com/articles/horizdropdowns
--><script type="text/javascript" src="../Scripts/mainmenu.js"></script>
<style type="text/css">
/*@import "../Styles/layout.css";*/
@import "../Styles/menustyle.css";
</style>
</head>
<body>
<p><img src="../Images/vtmlogo.png" width="151" height="75" hspace="2" vspace="0" /></p>
<ul id="nav"> 
  <li><a href="../../../org/userlogin/index.php">Home</a></li> 
  <li><a href="../../../org/Clients/clientlist.php">Clients</a> 
    <ul> 
  <li><a href="../../../org/Clients/clientlist.php">Client List</a> 
      <li><a href="../../../org/Contracts/contractsList_public.php">Contracts</a></li> 
      <li><a href="#">Team</a></li> 
      <li><a href="#">Offices</a></li> 
    </ul> 
  </li> 
  <li><a href="../../../org/Employees/Employee_list_full.php">Employees</a> 
    <ul> 
  <li><a href="../../../org/Employees/Employee_list_full.php">Employee List</a> 
      <li><a href="#">Org Chart</a></li> 
    </ul> 
  </li> 
    <li><a href="#">Projects </a> 
    <ul> 
      <li><a href="../../../org/Projects/projects_allactive.php">All Projects</a></li> 
      <li><a href="../../../org/Projects/projects_byClient.php">Projects by Client</a></li> 
      <li><a href="#">project what</a></li> 
    </ul> 
  </li> 

  <li><a href="../../../org/Timesheets/timesheet_redirect.php">Timesheets</a> 
    <ul> 
      <li><a href="../../../org/Timesheets/timesheet_main.php">New Timesheet </a></li> 
      <li><a href="../../../org/Timesheets/timesheet_redirect.php">Review Timesheets </a></li> 
      <li><a href="../../../org/Timesheets/timesheet_current.php">Current Timesheet</a></li> 
    </ul> 
  </li> 
  <li><a href="../../../org/ExpenseReports/erMain_R.php">Expense Reports </a> 
    <ul> 
      <li><a href="../../../org/ExpenseReports/erMain_C.php">New Expense Report </a></li> 
      <li><a href="../../../org/ExpenseReports/erMain_R.php">Review Expense Reports</a></li> 
      <li><a href="../../../org/ExpenseReports/erDetails_C.php">Current Expense Report</a></li> 
      <li><a href="../../../org/ExpenseReports/review_allexpenses.php">Review Expenses by Date</a></li> 
    </ul> 
  </li> 
</ul> 

<p></p>

<ul>
      <li><a href="../../../org/forum/">Help and Support</a></li> 

</ul>
</body>
</html>

 

No errors found.

Link to comment
Share on other sites

Yea, included files should not have the full out html like the file it is bbeing included to, that is where DW will screw you.

 

<!--//the functionality for the drop-down was provided here: http://www.alistapart.com/articles/horizdropdowns
-->
<script type="text/javascript" src="../Scripts/mainmenu.js"></script>
<style type="text/css">
/*@import "../Styles/layout.css";*/
@import "../Styles/menustyle.css";
</style>

<p><img src="../Images/vtmlogo.png" width="151" height="75" hspace="2" vspace="0" /></p>
<ul id="nav"> 
  <li><a href="../../../org/userlogin/index.php">Home</a></li> 
  <li><a href="../../../org/Clients/clientlist.php">Clients</a> 
    <ul> 
  <li><a href="../../../org/Clients/clientlist.php">Client List</a> 
      <li><a href="../../../org/Contracts/contractsList_public.php">Contracts</a></li> 
      <li><a href="#">Team</a></li> 
      <li><a href="#">Offices</a></li> 
    </ul> 
  </li> 
  <li><a href="../../../org/Employees/Employee_list_full.php">Employees</a> 
    <ul> 
  <li><a href="../../../org/Employees/Employee_list_full.php">Employee List</a> 
      <li><a href="#">Org Chart</a></li> 
    </ul> 
  </li> 
    <li><a href="#">Projects </a> 
    <ul> 
      <li><a href="../../../org/Projects/projects_allactive.php">All Projects</a></li> 
      <li><a href="../../../org/Projects/projects_byClient.php">Projects by Client</a></li> 
      <li><a href="#">project what</a></li> 
    </ul> 
  </li> 

  <li><a href="../../../org/Timesheets/timesheet_redirect.php">Timesheets</a> 
    <ul> 
      <li><a href="../../../org/Timesheets/timesheet_main.php">New Timesheet </a></li> 
      <li><a href="../../../org/Timesheets/timesheet_redirect.php">Review Timesheets </a></li> 
      <li><a href="../../../org/Timesheets/timesheet_current.php">Current Timesheet</a></li> 
    </ul> 
  </li> 
  <li><a href="../../../org/ExpenseReports/erMain_R.php">Expense Reports </a> 
    <ul> 
      <li><a href="../../../org/ExpenseReports/erMain_C.php">New Expense Report </a></li> 
      <li><a href="../../../org/ExpenseReports/erMain_R.php">Review Expense Reports</a></li> 
      <li><a href="../../../org/ExpenseReports/erDetails_C.php">Current Expense Report</a></li> 
      <li><a href="../../../org/ExpenseReports/review_allexpenses.php">Review Expenses by Date</a></li> 
    </ul> 
  </li> 
</ul> 

<p></p>

<ul>
      <li><a href="../../../org/forum/">Help and Support</a></li> 

</ul>

 

Try that out, and see where it gets you, you may need to move the style/javascript into the <head> tag or the header.inc.php include.

Link to comment
Share on other sites

that took care of the 'unenclosed tag' error in DW. Thanks a lot for all your help, Frost and TreeNode (awesome name btw)

 

But it still won't fire my javascript further up in the page if I include the menu. argh. guess I'm off to the javascript forum

 

Link to comment
Share on other sites

It should work as long as you have only 1 javascript onload event. It's easier to just create a single onload javascript function and refer to that. Like someone said earlier, your include files shouldn't actually have headers themselves (unless you have exceptions in the php code to handle that situation).

Link to comment
Share on other sites

It's easier to just create a single onload javascript function and refer to that

 

hmmm. sounds like a good idea.

 

I have these in 2 files:

 

window.onload=writeCurrName;

window.onload=startList;

 

how would you refer to the onload if I got rid of these and instead just had one:

 

window.onload=loadevent;

 

function loadevent(){

writeCurrName;

startList;

}

 

I tried this and it didn't work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.