OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: osCommerce W3C Validation
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Tips and Tricks
googlejunky
osCommerce W3C Validation

A few things to fix to make osCommerce Validate
Some are mistakes that should be fixed in osCommerce and some are just nitpicky things



BODY TAG
--------------------
The Body tag in osCommerce is redundant since the CSS file does this already
Not needed
CODE
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

Should be <body> only

And add this to the BODY in the CSS
CODE
padding : 0;



DOCTYPE
------------------
It isn't really hurting anything but should be in the correct case anyway

All files with
CODE
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">


Should be
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



IMAGE BORDER
-------------------
Image border="0" can't be used
Wrong --> <img src="images/thisimage.gif" border="0" alt="">

Has to be in the css file
CODE
img
{
border: 0;
}


Location to change it:
includes/functions/htmloutput.php
2 places to take out border="0"


LET OTHERS SEE YOU VALIDATE
Adding HTML and CSS validation images to the site(if you want that sort of thing)
Adding the HTML validation link is simple because W3C offers referrer code.
The CSS link for W3C takes a little more help though.

Adding the CSS validation link to your site:

Add to /includes/functions/html_output.php file just before the last ?>
CODE
// Get current page url for W3C validation

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}



Then add this to the /includes/footer.php for the CSS Validation link
CODE
<?php echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri=' . curPageURL() . '"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>'; ?>





If you have anything else then feel free to add your thoughts. I'm sure this has been talked about before at sometime.


Good luck in all you do,
Google Junky
Coopco
Thankyou Googlejunkie for the idiots guide to osCommerce W3C Validation.

There are certainly a lot of files to edit, but is ok on the localhost on my PC, now for the website.
Coopco
The code for the footer causes a secure/insecure warning when going to ssl. Any thoughts?
Jack_mcs
In case you are not aware of it, there is a contribution that goes over some of the code changes necessary for validation. I don't know how useful it is but it is there. I think it is named html validation, or something like that.

Jack
Coopco
QUOTE (Jack_mcs @ Mar 23 2008, 02:42 PM) *
In case you are not aware of it, there is a contribution that goes over some of the code changes necessary for validation. I don't know how useful it is but it is there. I think it is named html validation, or something like that.

Jack

Thanks Jack, will check it out.
Glcustoms
QUOTE (Coopco @ Mar 22 2008, 10:26 PM) *
The code for the footer causes a secure/insecure warning when going to ssl. Any thoughts?

Try This:

CODE
<?php
if ( $HTTPS !='on')  {
?>
<?php echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri=' . curPageURL() . '"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>'; ?>
<?php
}
?>
Coopco
QUOTE (Glcustoms @ Mar 23 2008, 03:33 PM) *
Try This:

CODE
<?php
if ( $HTTPS !='on')  {
?>
<?php echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri=' . curPageURL() . '"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>'; ?>
<?php
}
?>

Thanks GLcustoms, that worked. I put it in a table to centre it, like:


<?php
if ( $HTTPS !='on') {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="smallText"><?php echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri=' . curPageURL() . '"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>'; ?></td>
</tr>
</table>
<?php
}
?>

Now, to apply the rest of the changes to the site.
Jan Zonjee
QUOTE (Jack_mcs @ Mar 23 2008, 04:42 AM) *
In case you are not aware of it, there is a contribution that goes over some of the code changes necessary for validation. I don't know how useful it is but it is there. I think it is named html validation, or something like that.

Do you mean Easy validate osC HTML? It is (mainly) about making sure the & in the url's are changed to &amp; in the links (if you don't use SEO url's) which makes the validator stop complaining about it.
Jack_mcs
QUOTE (Jan Zonjee @ Mar 23 2008, 02:47 AM) *
Do you mean Easy validate osC HTML? It is (mainly) about making sure the & in the url's are changed to &amp; in the links (if you don't use SEO url's) which makes the validator stop complaining about it.
That looks like the one I was thinking about. The description of it says, "Use this if you like to use http://validator.w3.org/ to check your HTML." which indicates it would be for the purpose discussed here. But I've never downloaded it so it may just be as you mention.

Jack
adam777
I have the INDEX.PHP validated for WC3, and now working through PRODUCT_INFO.PHP, but not sure how to fix the following from the WC3 validator ???:

QUOTE
Validation Output: 5 Errors

Line 182, Column 131: cannot generate system identifier for general entity "action".
…m.au/product_info.php?products_id=27&action=add_product" method="post"><table✉

An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs".

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&amp;" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and &aelig; are different characters.

If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem.

Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.

Line 182, Column 131: general entity "action" not defined and no default entity.
…m.au/product_info.php?products_id=27&action=add_product" method="post"><table✉

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 182, Column 137: reference to entity "action" for which no system identifier could be generated.
…roduct_info.php?products_id=27&action=add_product" method="post"><table borde✉

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 182, Column 130: entity was defined here.
…om.au/product_info.php?products_id=27&action=add_product" method="post"><tabl


Line 200, Column 303: end tag for element "A" which is not open.
…5" vspace="5"><br>Click to enlarge</a>');✉

The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occurred in a script section of your document, you should probably read this FAQ entry.

Line 214, Column 137: cannot generate system identifier for general entity "goto".
…meras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodi✉

An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs".

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&amp;" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and &aelig; are different characters.

If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem.

Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.

Line 214, Column 137: general entity "goto" not defined and no default entity.
…meras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodi✉

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 214, Column 141: reference to entity "goto" for which no system identifier could be generated.
…s.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodinfo.✉

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 214, Column 136: entity was defined here.
…ameras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprod
googlejunky
QUOTE (adam777 @ Mar 30 2008, 05:56 PM) *
I have the INDEX.PHP validated for WC3, and now working through PRODUCT_INFO.PHP, but not sure how to fix the following from the WC3 validator ???:




CODE
The & sign needs to be changed to &amp;


it would end up being
domain.au/product_info.php?products_id=27&amp;action=add_product" method="post">


Find this block of code in /includes/functions/general.php around line 154
It is for the tep_get_all_get_params function


CODE
function tep_get_all_get_params($exclude_array = '') {
    global $HTTP_GET_VARS;

    if (!is_array($exclude_array)) $exclude_array = array();

    $get_url = '';
    if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {
      reset($HTTP_GET_VARS);
      while (list($key, $value) = each($HTTP_GET_VARS)) {
        if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
          $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

CODE
The last line here that says
$get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

Change the & to &amp;
Let me know if it works for you. I wasn't able to test it, but it looked to be the solution.
adam777
QUOTE (googlejunky @ Mar 31 2008, 06:17 AM) *
CODE
The & sign needs to be changed to &
it would end up being
domain.au/product_info.php?products_id=27&action=add_product" method="post">


Find this block of code in /includes/functions/general.php around line 154
It is for the tep_get_all_get_params function
CODE
function tep_get_all_get_params($exclude_array = '') {
    global $HTTP_GET_VARS;

    if (!is_array($exclude_array)) $exclude_array = array();

    $get_url = '';
    if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {
      reset($HTTP_GET_VARS);
      while (list($key, $value) = each($HTTP_GET_VARS)) {
        if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {
          $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

CODE
The last line here that says
$get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

Change the & to &
Let me know if it works for you. I wasn't able to test it, but it looked to be the solution.


Thanks GoogleJunky!

I still have 3 more errors in PRODUCT_INFO.PHP


QUOTE
Validation Output: 3 Errors

Line 200, Column 303: end tag for element "A" which is not open.
…5" vspace="5"><br>Click to enlarge</a>');✉
The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

If this error occurred in a script section of your document, you should probably read this FAQ entry.

Line 214, Column 137: cannot generate system identifier for general entity "goto".
…meras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodi✉

An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs".

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters.

If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem.

Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.

Line 214, Column 137: general entity "goto" not defined and no default entity.
…meras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodi✉
This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 214, Column 141: reference to entity "goto" for which no system identifier could be generated.
…s.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodinfo.✉

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.

Line 214, Column 136: entity was defined here.
…ameras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprod
perfectpassion
QUOTE
Line 200, Column 303: end tag for element "A" which is not open.
…5" vspace="5"><br>Click to enlarge</a>');✉

in product_info.php find
CODE
&lt;script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>

change to:
CODE
&lt;script language="javascript" type="text/javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '<\/a>'; ?>');
//--></script>


QUOTE
Line 214, Column 137: cannot generate system identifier for general entity "goto".
…meras.com.au/redirect.php?action=url&goto=www.pandi.hp.com%2Fpandi-db%2Fprodi

in includes/functions/banner.php find:
CODE
      $banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $banner['banners_image'], $banner['banners_title']) . '</a>';

change to:
CODE
      $banner_string = '<a href="' . tep_href_link(FILENAME_REDIRECT, 'action=banner&amp;goto=' . $banner['banners_id']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $banner['banners_image'], $banner['banners_title']) . '</a>';


then try revalidating

Tom
adam777
There is a WRAP issue on the CONTACT_US.PHP page

QUOTE
Validation Output: 1 Error

Line 209, Column 50: there is no attribute "WRAP".
… <td><textarea name="enquiry" wrap="soft" cols="50" rows="15"></textarea></✉
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the <embed> element to incorporate flash media in a Web page, see the FAQ item on valid flash.
digilee
Not sure if this has been covered, but one small validation problem I was having was with the OTF Autothumb contribution.
Basically the & needed to be &amp;

In includes > functions > html_output.php find this line:

$image = '<img src="product_thumb.php?img=' . $src . '&w=' .
tep_output_string($width) . '&h=' . tep_output_string($height) . '"';

and replace it with:

$image = '<img src="product_thumb.php?img=' . $src . '&amp;w=' .
tep_output_string($width) . '&amp;h=' . tep_output_string($height) . '"';
googlejunky
QUOTE (adam777 @ Mar 31 2008, 01:41 AM) *
There is a WRAP issue on the CONTACT_US.PHP page


I don't see any real use in it.
I have taken the WRAP portion out of mine.

You can read about it here and make your own decision
http://www.htmlcodetutorial.com/forms/_TEXTAREA_WRAP.html



includes/functions/html_output.php
CODE
At about line 189
function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {

Replace with this line
function tep_draw_textarea_field($name, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {



2 lines after that you will see
CODE
$field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';

Replace with
$field = '<textarea name="' . tep_output_string($name) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';




/checkout_payment.php
CODE
At about line 330
this line of code
<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5', $comments); ?></td>

Replace with
<td><?php echo tep_draw_textarea_field('comments', '60', '5', $comments); ?></td>




/checkout_shipping.php
CODE
At about line 385 you will see
<td><?php echo tep_draw_textarea_field('comments', 'soft', '60', '5'); ?></td>

Replace with
<td><?php echo tep_draw_textarea_field('comments', '60', '5'); ?></td>



/contact_us.php
CODE
At about line 114
<td><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>

Replace with
<td><?php echo tep_draw_textarea_field('enquiry', 50, 15); ?></td>



/product_reviews_write.php
CODE
At about line 164
<td class="main"><?php echo tep_draw_textarea_field('review', 'soft', 60, 15); ?></td>

Replace with
<td class="main"><?php echo tep_draw_textarea_field('review', 60, 15); ?></td>



/tell_a_friend.php
CODE
At about line 199
<td><?php echo tep_draw_textarea_field('message', 'soft', 40, 8); ?></td>

Replace with
<td><?php echo tep_draw_textarea_field('message', 40, 8); ?></td>
adam777
Thankyou GoogleJunky!
tanicos
i have this big error when trying to validate..i tried using all the doctypes but nothing..w3c can't find my doctype

CODE
DOCTYPE Override in effect!

The detected DOCTYPE Declaration "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">" has been suppressed and the DOCTYPE for "HTML 4.01 Transitional" inserted instead, but even if no errors are shown below the document will not be Valid until you update it to reflect this new DOCTYPE.


and a lot of additional errors
googlejunky
QUOTE (tanicos @ Apr 28 2008, 06:39 PM) *
i have this big error when trying to validate..i tried using all the doctypes but nothing..w3c can't find my doctype

CODE
DOCTYPE Override in effect!

The detected DOCTYPE Declaration "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">" has been suppressed and the DOCTYPE for "HTML 4.01 Transitional" inserted instead, but even if no errors are shown below the document will not be Valid until you update it to reflect this new DOCTYPE.


and a lot of additional errors




Do you mind showing your sites url in the forum so I can take a look?
tanicos
QUOTE (googlejunky @ Apr 28 2008, 07:53 PM) *
Do you mind showing your sites url in the forum so I can take a look?

CODE
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.onlinetemplates.org%2F&charset=%28detect+automatically%29&doctype=Inline&group=0


thank you
googlejunky
QUOTE (tanicos @ Apr 28 2008, 08:43 PM) *
CODE
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.onlinetemplates.org%2F&charset=%28detect+automatically%29&doctype=Inline&group=0


thank you



You may want to find why the first 3 lines are coming up as the following

CODE
<br />
<b>Warning</b>: extract(): First argument should be an array in <b>/home/content/l/u/x/luxurystore/html/templates/includes/application_top.php</b> on line <b>223</b><br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


I think that is where the problem is. The validator shows these lines when using the option "Show Source"
tanicos
QUOTE (googlejunky @ Apr 28 2008, 11:46 PM) *
You may want to find why the first 3 lines are coming up as the following

CODE
<br />
<b>Warning</b>: extract(): First argument should be an array in <b>/home/content/l/u/x/luxurystore/html/templates/includes/application_top.php</b> on line <b>223</b><br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


I think that is where the problem is. The validator shows these lines when using the option "Show Source"

yes i see that too..but when i look at the source code i don't see that. this is line 223 from application.top:
extract($_SESSION, EXTR_SKIP);

i've got seo urls and the register globals module...very strange
googlejunky
tanicos,

Check out http://forums.oscommerce.com/index.php?showtopic=294856
I don't know if it is what you are looking for though. I'm not sure which contributions you are using.

There was only one other thread about it here
http://forums.oscommerce.com/index.php?showtopic=262200

Google Junky
tanicos
i'll install RC2 and redesign it....thanks anyway
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.