View Full Version : PHP & xHTML code validation

03-27-2007, 02:38 PM
When I use <?PHP something ?> in my xHTML document, W3C dont validate it as a valid xHTML document. What is the right way to right PHP in xHTML documents? Here is my sample PHP/xHTML code...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?PHP include ("config.php");
$rowsPerPage = 2;
$pageNum = 1;
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" type="text/css" href="global.css" />
<script language="javascript" type="text/javascript" src="genreload.js" ></script>
<body leftmargin="0" topmargin="35">
<table width="460" border="0" cellpadding="0" cellspacing="0">

<td width="198" height="156" align="left" valign="middle">
<a href="http://www.furnishersworld.co.uk" onmouseover="imgon('<?PHP echo $row['image_name']; ?>')" onmouseout="imgoff('<?PHP echo $row['image_name']; ?>')" target="_blank">
<img src="images/<?PHP echo $row['image']; ?>" name="<?PHP echo $row['image_name']; ?>" alt="Portfolio - Freelance Web Designer - Muhammad Uzair Usman" width="198" height="156" /></a></td>
<td width="262" align="left" valign="default" class="tdprt">
<?PHP echo $row['client']; ?><br />
<?PHP echo $row['cat_id']; ?><br />
<?php do{ if(!empty($req_rows)){
echo $req_rows['req_name'].", ";
}while($req_rows=mysql_fetch_array($req_results));?><br />
<?php do{ if(!empty($tech_rows)){
echo $tech_rows['tech_name'].", ";
}while($tech_rows=mysql_fetch_array($tech_results));?><br />
<strong>Complition Time:</strong>
<?PHP echo $row['time']; ?><br />
<span class="link"><a href="http://www.<?PHP echo $row['url']; ?>" onmouseover="imgon('<?PHP echo $row['image_name']; ?>')" onmouseout="imgoff('<?PHP echo $row['image_name']; ?>')" target="_blank">Visit Website</a></span>
<td colspan="2" height="24"><hr /></td>
<?PHP }?>
<td colspan="2" align="center" class="pagination">

03-27-2007, 02:46 PM
You can't send it as a file to the validator, you have to put in a url. The PHP needs to be parsed by the server, otherwise you'll get the errors

03-27-2007, 02:48 PM
okie, Thanks a lot.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum