Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP and XHTML 1.0 Validation

Status
Not open for further replies.

xWastedMindx

Technical User
Sep 3, 2002
67
US
Hello again.

I'm trying to Validate my PHP page to the XHTML 1.0 standards according to
Problem is, the Validator seems to be stuck on 2 things..
It throws errors at the following:

Code:
Line 71, column 76: document type does not allow element "table" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag 
 ...llpadding='5' cellspacing='0' width='275'>^
                                              
Line 73, column 56: document type does not allow element "form" here; missing one of "object", "applet", "map", "iframe", "ins", "del" start-tag 
 <form action=&quot;dvdpost.php&quot; method=&quot;post&quot; name=&quot;form_dvd&quot;>^

Problem is... the first chunk is the table output from my PHP code. How can I hide the PHP from the validator?

The second chunk, is just a form I have... and for some odd reason, the XHTML validator doesn't like it.
Don't <form> tags go outside the <table> tags?
If there's any errors I'm overlooking, please have at it.. because I'm seriously confused as to why it's not validating.
Code:
<form action=&quot;dvdpost.php&quot; method=&quot;post&quot; name=&quot;form_dvd&quot;>
<table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;4&quot;>
<tr>
	<td align=&quot;left&quot;>
	 <b>DVD Name</b>:<br />
	</td>
	<td align=&quot;left&quot;>
	  <input type=&quot;text&quot; name=&quot;dvdName&quot; id=&quot;dvdName&quot; maxlength=&quot;35&quot; size=&quot;15&quot; />
	</td>
</tr>
<tr>
	<td>
	 <b>DVD Price</b>:
	</td>
	<td>
	  <input type=&quot;text&quot; name=&quot;dvdPrice&quot; id=&quot;dvdPrice&quot; maxlength=&quot;5&quot; size=&quot;15&quot; />
	</td>
</tr>
<tr>
	<td colspan=&quot;2&quot; align=&quot;center&quot;>
	  <input type=&quot;submit&quot; value=&quot;Submit&quot; />  
	  <input type=&quot;reset&quot; value=&quot;Reset&quot; />
	</td>
</tr>
</table>
</form>
 
With the errors you are getting, the problem might be in a completely different part of the code. Which DOCTYPE are you using? Could you give your entire code or even better, post a link. PHP has nothing to do with the validation since it is executed on the server and when validator gets its hands on the code there's only the php output.
 
I'm using the XHTML 1.0 Transitional DocType.

Here's all my code.

Code:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<?php require(&quot;../includes/connect.php&quot;);?>


<html>
<head>
<title>Contact</title>

<style type=&quot;text/css&quot;>
.contactText {
color: darkgrey;
}


</style>

</head>

<body background=&quot;../images/newbackground.gif&quot; link=&quot;#0000FF&quot; vlink=&quot;#800080&quot; text=&quot;#000000&quot; style=&quot;margin-top:0; margin-left:0;&quot;>

  <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;760&quot;>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td width=&quot;760&quot; height=&quot;22&quot; align=&quot;left&quot; valign=&quot;top&quot;><img height=&quot;22&quot; width=&quot;760&quot; src=&quot;../images/newtopbar.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
   </tr>
  </table>
<table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; width=&quot;760&quot;>
<tr valign=&quot;top&quot; align=&quot;left&quot;>
<td>

  <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;136&quot;>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td width=&quot;15&quot; height=&quot;156&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;15&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;121&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;121&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td height=&quot;272&quot;></td>
	<td width=&quot;121&quot; align=&quot;left&quot; valign=&quot;top&quot;><img height=&quot;272&quot; width=&quot;121&quot; src=&quot;../images/newtkeyboard.jpg&quot; border=&quot;0&quot; alt=&quot;sidebar_hardware&quot; /></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;2&quot; height=&quot;209&quot;></td>
   </tr>
  </table>
</td>
<td>

  <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;401&quot;>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td width=&quot;45&quot; height=&quot;17&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;45&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;22&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;22&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;326&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;326&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;8&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;8&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;2&quot;></td>
	<td width=&quot;326&quot;><font color=&quot;#dde3ee&quot; size=&quot;+4&quot; face=&quot;Arial,Helvetica&quot;>  
	<a href=&quot;../index.php&quot;><img src=&quot;../images/logo.png&quot; width=&quot;273&quot; height=&quot;58&quot; border=&quot;0&quot; alt=&quot;&quot; /></a></font></td>

	<td></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;4&quot; height=&quot;52&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;356&quot; colspan=&quot;3&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>
	// DVD & CD Indexer</font></b><font face=&quot;Arial&quot; size=&quot;2&quot;>


<!-- ### BEGIN FORM ### -->
<?php
// Begin
	echo (&quot;<table border='1' align='center' cellpadding='5' cellspacing='0' width='275'>
	<tr><td width='140'><b>DVD Name</b></td> <!-- <td><b>DVD Price</b></td> --> </tr>&quot;);

// Define colors for the alternating rows
$color1 = &quot;#E5E5E5&quot;;
$color2 = &quot;#DEE3E7&quot;;
$row_count = &quot;0&quot;;

// Perform the Query
    $results = mysql_query(&quot;SELECT * FROM dvd&quot;) or die(mysql_error());

while ($row = mysql_fetch_array($results)) {

	$dvdName = $row[&quot;dvdName&quot;];
// temp removal 	$dvdPrice = $row[&quot;dvdPrice&quot;];

 // Some sort of equation that makes it work
$row_color = ($row_count % 2) ? $color1 : $color2;

 // Table output here
echo (&quot;<tr><td width='110' bgcolor='$row_color'>&quot;);
echo (showName($dvdName));
// tempt removal echo (&quot;</td><td bgcolor='$row_color'>$dvdPrice</td></tr>&quot;);

 // Adds 1 to the row count
$row_count++;
}
// Close out the table.
echo ('</table>');
      /**
 * showname
 * Returns formatted string with ellipsis if length exceeds
 * defined maximum
 * parameters:
 * myText -> string
 * returns:
 * formattedText -> string
**/
function showName($dvdName) {
   // set max characters
$max = 22;
   // if longer than max
   if (strlen($dvdName)>$max) {
      return(substr($dvdName, 0, $max-3) . &quot;...&quot;);

      }
return($dvdName);
}

?>


<form action=&quot;dvdpost.php&quot; method=&quot;post&quot; name=&quot;form_dvd&quot;>
<table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;4&quot;>
<tr>
	<td align=&quot;left&quot;>
	 <b>DVD Name</b>:<br />
	</td>
	<td align=&quot;left&quot;>
	  <input type=&quot;text&quot; name=&quot;dvdName&quot; id=&quot;dvdName&quot; maxlength=&quot;35&quot; size=&quot;15&quot; />
	</td>
</tr>
<tr>
	<td>
	 <b>DVD Price</b>:
	</td>
	<td>
	  <input type=&quot;text&quot; name=&quot;dvdPrice&quot; id=&quot;dvdPrice&quot; maxlength=&quot;5&quot; size=&quot;15&quot; />
	</td>
</tr>
<tr>
	<td colspan=&quot;2&quot; align=&quot;center&quot;>
	  <input type=&quot;submit&quot; value=&quot;Submit&quot; />  
	  <input type=&quot;reset&quot; value=&quot;Reset&quot; />
	</td>
</tr>
</table>
</form>


<!-- ### END FORM -->


	</font></td>

   </tr>
   <tr valign=&quot;bottom&quot; align=&quot;center&quot;>
	<td colspan=&quot;4&quot; height=&quot;65&quot;><?php include(&quot;../footer.php&quot;);?></td>
   </tr>
  </table>
</td>
<td>

  <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;223&quot;>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td width=&quot;16&quot; height=&quot;121&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;16&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;21&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;21&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;53&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;53&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;42&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;42&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;6&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;6&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;6&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;6&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;61&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;61&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
	<td width=&quot;18&quot;><img src=&quot;../images/dot_clear.gif&quot; width=&quot;18&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; /></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;116&quot; colspan=&quot;3&quot;><a href=&quot;../about.php&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>About</font></b></a></td>

	<td colspan=&quot;4&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;14&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;189&quot; colspan=&quot;6&quot;><a href=&quot;../personal.php&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>Portfolio</font></b></a></td>

	<td></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;17&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;128&quot; colspan=&quot;5&quot;><a href=&quot;../phpbb2/&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>Forums</font></b></a></td>

	<td colspan=&quot;2&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;20&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;122&quot; colspan=&quot;4&quot;><a href=&quot;../links.php&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>Links</font></b></a></td>

	<td colspan=&quot;3&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;21&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td></td>
	<td width=&quot;74&quot; colspan=&quot;2&quot;><a href=&quot;contact.php&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>Contact</font></b></a></td>

	<td colspan=&quot;5&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;87&quot;></td>
   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;2&quot;></td>
	<td> </td>

   </tr>
   <tr valign=&quot;top&quot; align=&quot;left&quot;>
	<td colspan=&quot;8&quot; height=&quot;225&quot;></td>
   </tr>
  </table>
</td>
</tr>
</table>
</body>
</html>

&quot;Hey...Where are all the chicks?&quot; -- unknown
 
This is an HTML question, and as such it is most appropriately posted in the HTML forum.

//Daniel
 
We were warned not to solve html problems here, so here's a fast solution (validated for me):

<td width=&quot;356&quot; colspan=&quot;3&quot;><b><font color=&quot;#000066&quot; size=&quot;+1&quot; face=&quot;Arial,Helvetica&quot;>
// DVD & CD Indexer</font></b><font face=&quot;Arial&quot; size=&quot;2&quot;>
...
</font>

I thought all font tags were deprecated and not to be used in XHTML, but seems Transitional can handle them. But they cannot hold objects. Remove this font tag, opening and closing and it should validate. Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top