Page 1 of 1

include file does not work with one page!?

Posted: Wed Oct 15, 2003 9:18 am
by jam_phan
Hello all,
I am pretty new to programming with php, but I can program in other languages. I currently have a website that is running off iis, asp and mysql that i'm trying to convert to apache, php and mysql. So here is the problem I'm having, I have an include file that inserts my logo and links onto every page, however this include file causes one of my pages not to load. The page loads fine without the include file and the include file works with every other page. On the troubled page I have two mysql connections, one loads a combo box the other displays the result of what the user selects in the combo box, could this be the problem? I also have another include file that loads on this page that works fine. Basically I have tried everything that I know to do, so any suggestions would help. I include the file this way:

include("./Include/Nav.inc");


Thanks in advance

Posted: Wed Oct 15, 2003 10:03 am
by Nay
It would be good if you can post up the whole file which you are having problems with. It might not be the include() itself, it also could be something else that is affecting the include().

-Nay

Posted: Wed Oct 15, 2003 10:13 am
by Demon
Try to include the file like this:
include "./Include/Nav.inc";

It might make a difference.

Posted: Wed Oct 15, 2003 10:15 am
by jam_phan
Here is the code I have in the page that does not work. I have the include file commented out so the page will load.

Code: Select all

</head>
<body bgcolor="#60605f" vlink="purple">
<script language="javascript">
function submitform(){
	document.shows.submit()
}
</script>
<?php
#include("./Include/Nav.inc");
$db = mysql_connect("Localhost", "UserName", "Password");
mysql_select_db("Table", $db);
?>
<Form id=shows name=shows method=get action="shows.php">
<P align="center">
  Select Band:
  <SELECT id=Band style="WIDTH: 250" name=Band onchange="submitform()">
		<OPTION selected></OPTION>
		<?php
			$bands = mysql_query("Select BandName, BandID From Band Order By BandName", $db);
			while ($myrow = mysql_fetch_array($bands)){
				printf ("<option value='%s'>%s</option>", $myrow["BandID"], $myrow["BandName"]);
			}						
		?>
  </SELECT> 
  Or View All By:
  <SELECT id=order style="WIDTH: 138px" name=order onchange="submitform()">
    <OPTION selected></OPTION>
    <OPTION value="Date">Date</OPTION>
    <OPTION value="Venue">Venue</OPTION>
    <OPTION value="BandName">Band</OPTION>
    <OPTION value="Event">Event</OPTION>
    <OPTION value="State">State</OPTION>
  </SELECT> 
</P>
</Form>
<?php
echo "<Table border='1' align='center'>";
echo "<tr> <td> <B>Band </td> <td> <B>Date</td> <td><B>Venue</td> <td><B>City</td> <td><B>State</td> <td><B>Event</td> <td><B>Comment</TD> <td>Format</td> </tr>";
$result = mysql_query("SELECT b.BandName, Date, city, state, venue, event, comment, format FROM Band b inner join Shows s on s.bandid = b.bandid order by BandName, Date", $db);

while ($myrow = mysql_fetch_array($result)){
		printf ("<tr> <td>%s</td> <td nowrap>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> </tr>\n", $myrow["BandName"], $myrow["Date"], $myrow["venue"], $myrow["city"], $myrow["state"], $myrow["event"], $myrow["comment"], $myrow["format"]);
}
echo "</table>";
include("./Include/Bottom.inc");
?>
</body>
Admin Edit: PHP tags added for clarity and spaces added to allow wrapping

Posted: Wed Oct 15, 2003 10:18 am
by jam_phan
Here is the code for the include file, it is a little hard to read because it was generated by fireworks.

Code: Select all

<script language="JavaScript">
<!--
function MM_findObj(n, d) &#123; //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) &#123;
    d=parent.frames&#1111;n.substring(p+1)].document; n=n.substring(0,p);&#125;
  if(!(x=d&#1111;n])&&d.all) x=d.all&#1111;n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms&#1111;i]&#1111;n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers&#1111;i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
&#125;
function MM_nbGroup(event, grpName) &#123; //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) &#123;
    if ((img = MM_findObj(args&#1111;2])) != null && !img.MM_init) &#123;
      img.MM_init = true; img.MM_up = args&#1111;3]; img.MM_dn = img.src;
      if ((nbArr = document&#1111;grpName]) == null) nbArr = document&#1111;grpName] = new Array();
      nbArr&#1111;nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args&#1111;i])) != null) &#123;
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args&#1111;i+1];
        nbArr&#1111;nbArr.length] = img;
    &#125; &#125;
  &#125; else if (event == "over") &#123;
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args&#1111;i])) != null) &#123;
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args&#1111;i+2]) ? args&#1111;i+2] : ((args&#1111;i+1])?args&#1111;i+1] : img.MM_up);
      nbArr&#1111;nbArr.length] = img;
    &#125;
  &#125; else if (event == "out" ) &#123;
    for (i=0; i < document.MM_nbOver.length; i++) &#123; img = document.MM_nbOver&#1111;i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; &#125;
  &#125; else if (event == "down") &#123;
    nbArr = document&#1111;grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) &#123; img=nbArr&#1111;i]; img.src = img.MM_up; img.MM_dn = 0; &#125;
    document&#1111;grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args&#1111;i])) != null) &#123;
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args&#1111;i+1])? args&#1111;i+1] : img.MM_up;
      nbArr&#1111;nbArr.length] = img;
  &#125; &#125;
&#125;

function MM_preloadImages() &#123; //v3.0
 var d=document; if(d.images)&#123; if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a&#1111;i].indexOf("#")!=0)&#123; d.MM_p&#1111;j]=new Image; d.MM_p&#1111;j++].src=a&#1111;i];&#125;&#125;
&#125;

//-->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="501" align="center">
<!-- fwtable fwsrc="JamPhanLight.png" fwbase="JamPhanLight.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
  <tr>
   <td><img src="images/spacer.gif" width="106" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="73" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="34" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="81" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="29" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="71" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="68" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="38" height="1" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>

  <tr>
   <td rowspan="3"><img name="JamPhanLight_r1_c1" src="images/JamPhanLight_r1_c1.gif" width="106" height="225" border="0" alt=""></td>
   <td rowspan="3"><img name="JamPhanLight_r1_c2" src="images/JamPhanLight_r1_c2.gif" width="73" height="225" border="0" usemap="#m_JamPhanLight_r1_c2" alt=""></a></td>
   <td colspan="6"><img name="JamPhanLight_r1_c3" src="images/JamPhanLight_r1_c3.gif" width="321" height="33" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="33" border="0" alt=""></td>
  </tr>
  <tr>
   <td colspan="3"><img name="JamPhanLight_r2_c3" src="images/JamPhanLight_r2_c3.gif" width="144" height="1" border="0" alt=""></td>
   <td rowspan="2"><img name="JamPhanLight_r2_c6" src="images/JamPhanLight_r2_c6.gif" width="71" height="192" border="0" usemap="#m_JamPhanLight_r2_c6" alt=""></td>
   <td rowspan="2" colspan="2"><img name="JamPhanLight_r2_c7" src="images/JamPhanLight_r2_c7.gif" width="106" height="192" border="0" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>
  <tr>
   <td><img name="JamPhanLight_r3_c3" src="images/JamPhanLight_r3_c3.gif" width="34" height="191" border="0" usemap="#m_JamPhanLight_r3_c3" alt=""></td>
   <td><img name="JamPhanLight_r3_c4" src="images/JamPhanLight_r3_c4.gif" width="81" height="191" border="0" usemap="#m_JamPhanLight_r3_c4" alt=""></td>
   <td><img name="JamPhanLight_r3_c5" src="images/JamPhanLight_r3_c5.gif" width="29" height="191" border="0" usemap="#m_JamPhanLight_r3_c5" alt=""></td>
   <td><img src="images/spacer.gif" width="1" height="191" border="0" alt=""></td>
  </tr>
<map name="m_JamPhanLight_r1_c2">
<area shape="poly" coords="xxx" href="http://www.jamphan.com" title="home" alt="home" >
<area shape="poly" coords="0,211,14,248,52,248,73,215,61,-19,27,-10,0,211" href="/Pics.php" alt="" onMouseOut="MM_nbGroup('out');"  onMouseOver="MM_nbGroup('over', 'JamPhanLight_r1_c2', 'images/JamPhanLight_r1_c2_f6.gif', 'images/JamPhanLight_r1_c2_f7.gif', 1);"  onClick="MM_nbGroup('down', 'navbar1', 'JamPhanLight_r1_c2', 'images/JamPhanLight_r1_c2_f7.gif', 1);"  >
</map>
<map name="m_JamPhanLight_r2_c6">
<area shape="poly" coords="xxx" href="http://www.jamphan.com" title="home" alt="home" >
<area shape="rect" coords="12,167,63,189" href="/MessageBoard.php" alt="" onMouseOut="MM_nbGroup('out');"  onMouseOver="MM_nbGroup('over','JamPhanLight_r2_c6', 'images/JamPhanLight_r2_c6_f2.gif', 'images/JamPhanLight_r2_c6_f3.gif', 1);"  onClick="MM_nbGroup('down', 'navbar1', 'JamPhanLight_r2_c6', 'images/JamPhanLight_r2_c6_f3.gif', 1);"  >
</map>
<map name="m_JamPhanLight_r3_c3">
<area shape="poly" coords="xxx" href="http://www.jamphan.com" title="home" alt="home" >
</map>
<map name="m_JamPhanLight_r3_c4">
<area shape="poly" coords="xxx" href="http://www.jamphan.com" title="home" alt="home" >
<area shape="rect" coords="10,168,65,184" href="/Shows.php" alt="" onMouseOut="MM_nbGroup('out');"  onMouseOver="MM_nbGroup('over', 'JamPhanLight_r3_c4', 'images/JamPhanLight_r3_c4_f2.gif', 'images/JamPhanLight_r3_c4_f3.gif', 1);"  onClick="MM_nbGroup('down', 'navbar1', 'JamPhanLight_r3_c4', 'images/JamPhanLight_r3_c4_f3.gif', 1);"  >
</map>
<map name="m_JamPhanLight_r3_c5">
<area shape="poly" coords="xxx" href="http://www.jamphan.com" title="home" alt="home" >
</map>
</table>
Admin Edit: CODE tags added for clarity and coordinates removed from <area> tags to allow the page to wrap.

Posted: Wed Oct 15, 2003 10:18 am
by zenabi
Is the "problem" page in a different folder to the others?

Posted: Wed Oct 15, 2003 10:22 am
by Stoneguard
You have a </head> tag in both files, for a start. Make sure you dont have multiple <head></head> sections.

Posted: Wed Oct 15, 2003 10:22 am
by jam_phan
The page with the problems is in the same directory as all the other pages and I just tried to include the file as Demon suggested and it still does not work.

Posted: Wed Oct 15, 2003 10:27 am
by jam_phan
Well I took out both the </head> and <body> tags out of the include file, still no fix.

Posted: Thu Oct 16, 2003 3:57 am
by twigletmac
Firstly, any <script> tags should be in the main <head></head> tags - you need to strip these out from the included file and put them into the main page.

Your page tags should be structured something like:

Code: Select all

<html>
<head>
<title>Page Title</title>
<script language="Javascript">
// all Javascript functions here including those for the navigation
</script>
</head>

<body>
// include file

// rest of page content
</body>
</html>
It would be useful if you checked the source of the page once it's loaded and tell us what is there.

Mac

Posted: Thu Oct 16, 2003 7:49 am
by Stoneguard
Err, actually script tags are non-dependent on any other tags. Most people include them in the header to ensure the scripting gets downloaded before the body of the page downloads, but you only need that if you are executing functions before the whole page finishes loading.

Posted: Thu Oct 16, 2003 8:38 am
by twigletmac
Arg, I was thinking of style tags (but I still think it's a good thing to have them all in one place).

Mac