Forum Moderators: open

Message Too Old, No Replies

php/js causing xthml validation error

validator doesn't see the doctype

         

varya

2:04 am on Dec 19, 2006 (gmt 0)

10+ Year Member



I'm going nuts, 'cause I can't figure this out. First of all, the files validate if I use the file upload option to validate, but the same files fail if I validate by url.

For some reason, the javascript line in the php is causing the validator to miss the doctype.

Would appreciate help solving this problem. Thanks.

<?php

if (!isset($_COOKIE['widgetcookie'])) {
// if a cookie does not exist
// set it
setcookie("widgetcookie", "1", mktime()+86400, "/") or die("Could not set cookie");
{
// pops access confirmation box
function confirm($msg)
{
echo "<script language=\"javascript\">alert(\"".$msg."\");<\/script>";
}//end function
}

$msg = "lorem ipsum delor.";
confirm($msg);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

alfaguru

5:51 pm on Dec 19, 2006 (gmt 0)

10+ Year Member



You are sending the SCRIPT element before the DOCTYPE. The DOCTYPE must be the first thing in the document. Do the cookie test you send before the DOCTYPE and set a flag value you can test after it, at a point in the document where SCRIPT is valid.