Jump to content

Repetition unexpected


Matpatnik

Recommended Posts

Hi guys,I have a weird result in my page, it duplicate the footer in the bg of the page and keep going untill the browser crash!here is the pages:

/***** head.php *****/<?php// close the main table, the database and the pagefunction getfooter($ect) {	include ("foot.php");}?>/***** main page *****/<?phpinclude "head.php";$wsql = "SELECT welcome_title, welcome_intro FROM welcome " .		"ORDER BY welcome_lastmod DESC " .		"LIMIT '" . $a_welcome . "'";$wresult = mysql_query($wsql)	or die(mysql_error());while($wrow = mysql_fetch_array($wresult)) {	echo "<div class=\"feature\">\n 		  <h3>" . $wrow['welcome_title'] . "</h3>\n 		  <p>" . BBCode($wrow['welcome_intro']) . "</p>\n		  </div>\n";}$nsql = "SELECT * FROM news 		ORDER BY news_lastmod DESC 		LIMIT '" . $a_lastnews . "'";$nresult = mysql_query($nsql)	or die(mysql_error());while($nrow = mysql_fetch_array($nresult)) {	if ($nrow['news_date'] == $nrow['news_lastmod']) {		$lastmod = "";	} else {		$lastmod = "Last modification: " . $nrow['news_lastmod'];	}?>  	<div class="story"> 	  <p><?php	echo "<a href=\"#\" class=\"capsule\">" . $nrow['news_title'] . "</a><br>";	echo BBCode($nrow['news_info']) . "<br>";	echo "<span class=\"small\">" . $nrow['news_date'] . " " . $lastmod . "</span></div>";?>				  </p><hr> 	</div><?php}echo "We have " . mysql_num_rows($result) . " differents pictures on our site<br>\n";echo "hey\n";getfooter($ect);?>/***** foot.php *****/   </div>  <div id="siteInfo"> 	<img src="" width="44" height="22"> <a href="#">About Us</a> | <a href="#">Site	Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | © 2002 - 2007  </div> </div> <!--end pagecell1--> <br> <"script type="text/javascript">	<!--	  var menuitem1 = new menu(7,1,"hidden");			var menuitem2 = new menu(7,2,"hidden");			var menuitem3 = new menu(7,3,"hidden");			var menuitem4 = new menu(7,4,"hidden");			var menuitem5 = new menu(7,5,"hidden");			var menuitem6 = new menu(7,6,"hidden");			var menuitem7 = new menu(7,7,"hidden");	// -->	</script></body></html><?phpmysql_close($connect);?>

any idea of what can cause that duplication?Thank you for your help

Link to comment
Share on other sites

It might be because the include is in a function. That alone should not cause any recursion though. Try replacing the function call to getfooter with the include statement. Also, this doesn't affect anything else, but you have a parameter called $ect in the getfooter function and you don't use it anywhere in the function. Also, the function call passes a variable called $ect but that variable is not defined. It looks like you copied this code from somewhere else and did not remove the parts you don't need. There is also an extra quote in the <script> tag in the footer, that might be causing problems with some javascript. I think you also left some code out, because I don't see any <html> or <body> tags or anything like that. Do you have a link to an example?

Link to comment
Share on other sites

I have fixed the repetition. I think the 2nd while statement didn't like to ouside and inside of the php code.The $ect variable is the connection to the database and no I did the code by my own :) except for the template and the JavaScript which was in it.I'm trying to mould the template the way I need it :)

Link to comment
Share on other sites

here my page, things work good except the footer which show up in the header and the JavaScript in the footer You can have a quick look :)[edited] I do change some variable name and erase some part of the code but only is it's important to keep it "secret" or if it's useless[/edited]

Link to comment
Share on other sites

There's more going on in your code then what I can tell from what you've posted. For example, the very first thing on the page is this:<div id="content">There are several other problems as well, like this list:<ul class="listupperroman"><br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /><li> Text<br /></ul><br />You will probably want to validate the page first, the validator showed over 35 errors. The footer is appearing on the top of the page probably because of one of the errors. The footer tries to close a div that is not open, for example.

Link to comment
Share on other sites

Yes I realise that I've closed the feature id before open it :) I will validate the page now, everything is fine except the JavaScriptthe <ul class="listupperroman"><br /><li> Text<br />...it's probably while I type the bbcode I press enter for each tag and when display on the browser it look at avery breaking point in the database.

Link to comment
Share on other sites

I just view the page and there is a Javascript problem someplace. 600 errors makes me think the script is looping badly. Seems to increase the fastest when the mouse moves?

Error: menuitem1 has no propertiesSource File: http://www.stoneshowroom.ca/phpindex4.phpLine: 36

Link to comment
Share on other sites

I also looked at that and there is a problem that occurs before that "menuitem1 has no properties" error:

this.thediv has no propertieshttp://www.stoneshowroom.ca/phpindex4.php#Line 21
It looks like you are creating the menu objects like this:
var menuitem1 = new menu(7,1,"hidden");

Which then runs this code:

divname="subglobal"+thisitem;...this.thediv = document.getElementById(divname);

Whichs tells the DOM that there is an element with an id of "subglobal1". However, there aren't any elements in your HTML with an id of "subglobal1", it starts with "subglobal2" and goes up to "subglobal8". Fix that and you might fix all the javascript bugs.

Link to comment
Share on other sites

Thank you guysNow the JavaScript is working perfectly after I fixed the subglobal1 like jesh said.I did validate the page except for the bbcode that I will have to find a way to escape the line breaking inside of the of the <ul></ul>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...