Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with validation of code from php include

Featured Replies

I could really use some help with passing validation on the new website I'm building. I have several "XML Parsing Error: Opening and ending tag mismatch..." when trying to validate the page. The page uses an include to bring in the menu (nav.php). If I copy and paste the code of the page in (without the include code) the page validates with the exception of an iframe issue (still sorting that out).

 

The validation process appears to be picking up closing tags that are conditional in the php. How to I address that?

 

the page in question is here: http://carpenterimages.com/kattas/acrylic_stained_canvas.php

 

Any help that can be provided would be appreciated.

 

Thank you!

I would suggest posting up the actual code of the page first.

 

Welcome to WDF, by the way.

You had IE6 conditional comments missing and </li> and </ul> tags in the wrong place. This now validates the menu (only one error relating to attribute onload) note the groupings for clarity:-

 

<div id="nav">
<!--xxx spacer xxx -->
<ul class="select">
<li><a href="index.php?current=one&sub=none">HOME</a></li>
</ul>
<!--xxx spacer xxx -->
<ul class="current">			
<li><a href="acrylic_stained_canvas.php?current=two&sub=none">PAINTINGS

<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->

<ul class="sub_active"> 

<li class="current_sub"><a href="acrylic_stained_canvas.php?current=two&sub=a">Acyrlic Stained Canvas</a></li>

<li><a href="acrylic_washes.php?current=two&sub=b">Acrylic Washes on Paper</a></li> 

<li><a href="paintings_installations.php?current=two&sub=c">Installation Views</a></li>
</ul>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

</ul>
<!--xxx spacer xxx -->
<ul class="select"> 

<li><a href="collage.php?current=three&sub=none">COLLAGE

<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->

<ul class="sub"> 

<li><a href="collage.php?current=three&sub=a"> Works</a></li> 

<li><a href="collage_install.php?current=three&sub=b">Installation Views</a></li>				
</ul> 

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

</ul>
<!--xxx spacer xxx -->	
<ul class="select">
<li><a href="montage.php?current=four&sub=none">MONTAGE</a></li>
</ul> 


<!--xxx spacer xxx -->
<ul class="select">
<li><a href="posters.php?current=five&sub=none">POSTERS</a></li>
</ul> 


<!--xxx spacer xxx -->
<ul class="select">
<li><a href="artist.php?current=six&sub=none">ARTIST'S STATEMENT</a></li>
</ul>

<!--xxx spacer xxx -->
<ul class="select"> 
<li><a href="contact.php?current=seven&sub=none">CONTACT</a></li>
</ul> 


<!--xxx spacer xxx -->
</div>

  • Author

I should have known to post the code! I made the suggested changes to the menu, but they made no difference. In part, I'm sure, because the menu html is generated by php code.

 

So....here is more information.

 

The first page's code (http://carpenterimages.com/kattas/acrylic_stained_canvas.php) is here:

 

----------------------

<!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=UTF-8" />

<title>Susan Kattas - Acrylic Stained Canvas</title>

<link href="main.css" rel="stylesheet" type="text/css" />

<style type="text/css">

 

 

 

</style>

 

 

<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

 

</head>

 

<body class="main">

 

 

 

<div id="wrapper">

<div id="top">

</div>

<div id="container">

 

<div id="header">

<h1><img src="images/header.jpg" alt="Susan Kattas Logo" width="900" height="91" /></h1>

<!-- end #header --></div>

 

 

<div id="menu">

 

 

<?php

$current = "two";

$sub="a";

include("nav.php");

?>

 

</div>

<div id="mainContent">

 

<div id="portfolio">

<p align="center">

<iframe src="acrylic/album/index.html" name="frame1" style="visibility:hidden;" onload="this.style.visibility = 'visible';"

width="90%" height="500"

align="middle" frameborder="0" scrolling="no"> </iframe>

</p>

<p align="center"><em><a href="contact.php"> Contact</a> the artist for shipping and delivery costs </em></p>

<!---end #portfolio --></div></div>

 

<!-- end #container --></div>

</div>

<div id="footer">

<p align="center">

<!-- end #footer -->

<span class="style2"> Copyright ©2009 Susan Kattas<br />

</span> </p>

 

</div>

</body>

</html>

-----------------------------------------

******************************************************

The nav.php (which I think is the source of the problem) that is brought in via the include is here:

 

 

<div id="nav">

<?php

if($current == "one")

{

echo "<ul class=\"current\">";

}

else

{

echo "<ul class=\"select\">";

}

?>

<li><a href="index.php?current=one&sub=none">HOME</a></li>

</ul>

 

<!--xxx spacer xxx -->

 

<?php

if ($current == "two")

{

echo "<ul class=\"current\">";

}

else {

echo "<ul class=\"select\">";

}

?>

 

 

<li><a href="acrylic_stained_canvas.php?current=two&sub=none">PAINTINGS

 

<?php

if ($current == "two")

{

echo "</a></li></ul><ul class=\"sub_active\">";

}

else {

echo "<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class=\"sub\">";

}

?>

 

 

 

 

<?php

if ($current == "two" && $sub == "a")

{

echo "<li class=\"current_sub\">";

}

else {

echo "<li>";

}

?>

<a href="acrylic_stained_canvas.php?current=two&sub=a">Acyrlic Stained Canvas</a></li>

 

<?php

if ($current == "two" && $sub == "b")

{

echo "<li class=\"current_sub\">";

}

else {

echo "<li>";

}

?>

<a href="acrylic_washes.php?current=two&sub=b">Acrylic Washes on Paper</a></li>

 

<?php

if ($current == "two" && $sub == "c")

{

echo "<li class=\"current_sub\">";

}

else {

echo "<li>";

}

?>

 

<a href="paintings_installations.php?current=two&sub=c">Installation Views</a></li>

</ul>

<?php

if ($current == "two")

{

echo "";

}

else {

echo "<!--[if lte IE 6]></td></tr></table></a><![endif]-->";

}

?>

 

</li>

 

</ul>

 

<!--xxx spacer xxx -->

 

<?php

if ($current == "three")

{

echo "<ul class=\"current\">";

}

else {

echo "<ul class=\"select\">";

}

?>

 

 

<li><a href="collage.php?current=three&sub=none">COLLAGE

 

<?php

if ($current == "three")

{

echo "</a></li></ul><ul class=\"sub_active\">";

}

else {

echo "<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class=\"sub\">";

}

?>

 

 

 

<?php

if ($current == "three" && $sub == "a")

{

echo "<li class=\"current_sub\">";

}

else {

echo "<li>";

}

?>

<a href="collage.php?current=three&sub=a"> Works</a></li>

 

<?php

if ($current == "three" && $sub == "b")

{

echo "<li class=\"current_sub\">";

}

else {

echo "<li>";

}

?>

<a href="collage_install.php?current=three&sub=b">Installation Views</a></li>

 

</ul>

<?php

if ($current == "three")

{

echo "";

}

else {

echo "<!--[if lte IE 6]></td></tr></table></a><![endif]-->";

}

?>

 

</li>

 

</ul>

 

<!--xxx spacer xxx -->

<?php

if($current == "four")

{

echo "<ul class=\"current\">";

}

else

{

echo "<ul class=\"select\">";

}

?>

 

 

<li><a href="montage.php?current=four&sub=none">MONTAGE</a></li>

</ul>

 

 

<!--xxx spacer xxx -->

<?php

if($current == "five")

{

echo "<ul class=\"current\">";

}

else

{

echo "<ul class=\"select\">";

}

?>

<li><a href="posters.php?current=five&sub=none">POSTERS</a></li>

</ul>

 

<!--xxx spacer xxx -->

<?php

if($current == "six")

{

echo "<ul class=\"current\">";

}

else

{

echo "<ul class=\"select\">";

}

?>

 

<li><a href="artist.php?current=six&sub=none">ARTIST'S STATEMENT</a></li>

</ul>

 

<!--xxx spacer xxx -->

<?php

if($current == "seven")

{

echo "<ul class=\"current\">";

}

else

{

echo "<ul class=\"select\">";

}

?>

 

<li><a href="contact.php?current=seven&sub=none">CONTACT</a></li>

</ul>

 

</div>

 

 

Again,

 

Thanks in advance for your help!

You're right! You have to edit the PHP file inside all those echo statements and remember to cancel all the " with a backslash like \" for any bits of html code like image urls or id="..." etc, but not if they are part of the PHP code.

 

Too time consuming for me to do right now, but I assure you my version is correct; I tested a page to make sure the drop down menu worked and that it validated.

 

Best of luck.

  • Author

" cancel all the " with a backslash like \" for any bits of html code like image urls or id="..." etc, but not if they are part of the PHP code."

 

I'm very new to the php...it was a real struggle getting this far. I'm not entirely clear what I need to do based on your statement above. Would you have time to just give a quick example of one of the lines of my code? Completely understand if you don't.

 

Thanks

The PHP is always inside <?PHP............?> tags. Anything inside there which you recognise as html like class="current" has to have the " cancelled so that the PHP doesn't think it's part of the PHP code and it's already been done like echo "<ul class=\"current\">"; so you don't have to edit those bits which are just setting the PHP code to identify the current page with a different style.

 

The menu code is largely outside the <?PHP.....?> tags like this:-

?>

 

<li><a href="acrylic_stained_canvas.php?current=two&sub=none">PAINTINGS

 

<?php

 

where one bit of PHP has been closed with ?> and then there is some html which doesn't need the " cancelled then another bit of PHP starts with <?PHP

so looking at the code more closely you probably need to edit all the bits between the PHP code sections, using my code as a guide.

 

However, there are some bits of html inside the php tags like

else {

echo "<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class=\"sub\">";

}

?>

 

 

and

 

else {

echo "<li>";

}

 

so it looks a bit muddled to me. I've never seen php includes set up in such a complicated way.

  • Author

Thanks for the guidance. I'll take a stab at getting this corrected and see where I end up. I used the dropline menu code from Stu Nichols CSS Play site. Getting the active menu item to display correctly has been a real pain. Not sure I would know how to do it any other way.

 

We'll see where I can get it.

 

Your detailed explanation is very helpful!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.