Forum Moderators: coopster
New to PHP, infact just started to learn. My problem is this: I have just built my first website but have added a couple of php scripts (include files) for a counter etc (until I can write my own).
My site is in xhtml 1.0 transitional and the counter works fine but just checked the w3c validation site and it shows errors against my line 129 which is as follows:
<div id="counter"> <span class="countertext">you are visitor</span>
<?php include("counter.php");?>
<span class="countertext"> thank you.</span> </div>
My question is this: If php is a server side language why do I get xhtml errors. I take it the errors are in the counter.php file.
Hope this makes sense to you.
thanks for taking the time to help
Shug
I did what you said and this is what I got back:
<div id="counter"><span class="countertext">you are visitor</span>
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/digits/9.gif> <span class="countertext"> thank you.</span> </div>
</div>
And these are the errors (15)on 1 line;
Line 128, column 15: an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/
Line 128, column 22: NET-enabling start-tag not immediately followed by null end-tag
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/
Line 128, column 22: required attribute "alt" not specified
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
Line 128, column 22: end tag for "img" omitted, but OMITTAG NO was specified
<img src=images/digits/1.gif ><img src=images/digits/6.gif><img src=images/
You may have neglected to close a tag, or perhaps you meant to "self-close" a tag; that is, ending it with "/>" instead of ">".
Line 128, column 6: start tag was here
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/
Line 128, column 44: an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified
...img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/digi
Line 128, column 51: NET-enabling start-tag not immediately followed by null end-tag
...=images/digits/1.gif><img src=images/digits/6.gif><img src=images/digits/9.gi
Line 128, column 51: required attribute "alt" not specified
...=images/digits/1.gif><img src=images/digits/6.gif><img src=images/digits/9.gi
Line 128, column 51: end tag for "img" omitted, but OMITTAG NO was specified
...=images/digits/1.gif><img src=images/digits/6.gif><img src=images/digits/9.gi
Line 128, column 35: start tag was here
<img src=images/digits/1.gif><img src=images/digits/6.gif><img src=images/
Line 128, column 73: an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified
...img src=images/digits/6.gif><img src=images/digits/9.gif> <span class="c
Line 128, column 80: NET-enabling start-tag not immediately followed by null end-tag
...=images/digits/6.gif><img src=images/digits/9.gif> <span class="countert
Line 128, column 80: required attribute "alt" not specified
...=images/digits/6.gif><img src=images/digits/9.gif> <span class="countert
Line 128, column 80: end tag for "img" omitted, but OMITTAG NO was specified
...=images/digits/6.gif><img src=images/digits/9.gif> <span class="countert
Line 128, column 64: start tag was here
...s/1.gif><img src=images/digits/6.gif><img src=images/digits/9.gif> <span
thanks for your time.
<img src="images/digits/1.gif" alt="your alt text here" />.
However, this must be part of the php include file and I dont know how to change it. The counter.php file has this code and is echo'd out
// print the image for that digit
echo "<img src=images/digits/$digit.$imgExtension>";
am I right that this needs changing? Sorry but very new at this. Thanks again.
// print the image for that digit
echo "<img src=images/digits/$digit.$imgExtension>";
Many ways to accomplish this, here are a few,
// use single quotes and escape them as necessary
echo '<img alt="description" src="images/digits/'. $digit . $imgExtension .'" />';
// use double quotes for php and escape them in the xhtml
echo "<img alt=\"description\" src=\"images/digits/". $digit . $imgExtension .\"" />";
// store everything in variables then concatenate
$image_begin = '<img alt="description" src="images/digits/';
$image_end = '" />';
echo $image_begin . $digit . $imgExtension . $image_end;
I use the first method.
// print the image for that digit
echo "<img src=images/digits/$digit.$imgExtension>";
The dot between $digit and $imgExtension isn't for concatinating but is seperating the filename from extension. Sorry, wasn't paying attention.
echo '<img alt="text" src="images/digits/'. $digit .'.'. $imgExtension .'>"';
but the way you did it looks cleaner :)