Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php image swap script not validating

    Hi, hope this is the correct place.

    I have a site that uses a fairly simple ( i say simple, i know nothing about php!) image swap script based on the current day.

    PHP Code:
    <?php
    $url 
    "http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/";
    $monImage "$url"."fix-3.jpg";
    $tueImage "$url"."fix-3.jpg";
    $wedImage "$url"."fix-1.jpg";
    $thurImage "$url"."fix-2.jpg";
    $friImage "$url"."fix-2.jpg";
    $satImage "$url"."fix-2.jpg";
    $sunImage "$url"."fix-2.jpg";
    $d date("D");
    //Function that switches between date images based on the actual day of the week in $d
    switch ($d)
    {
    case 
    Mon:
    echo 
    "<img src=$monImage>\n";
    break;
    case 
    Tue:
    echo 
    "<img src=$tueImage>\n";
    break;
    case 
    Wed:
    echo 
    "<img src=$wedImage>\n";
    break;
    case 
    Thu:
    echo 
    "<img src=$thurImage>\n";
    break;
    case 
    Fri:
    echo 
    "<img src=$friImage>\n";
    break;
    case 
    Sat:
    echo 
    "<img src=$satImage>\n";
    break;
    case 
    Sun:
    echo 
    "<img src=$sunImage>\n";
    }
    ?>
    Now it all works a treat, but the issue being that the site doesnt validate due to 4 errors relating to this script. I have tried and tried and cannot suss out what the problem is or how to fix it?

    Errors:

    Below are the results of checking this document for XML well-formedness and validity.

    Error Line 149 column 9: an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified.
    <img src=http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/fi✉

    Error Line 149 column 15: NET-enabling start-tag not immediately followed by null end-tag.
    <img src=http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/fiThis error may occur when there is a mistake in how a self-closing tag is closed, e.g '.../ >'. The proper syntax is '... />' (note the position of the space).



    Error Line 149 column 15: required attribute "alt" not specified.
    <img src=http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/fiThe 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>.



    Error Line 149 column 15: end tag for "img" omitted, but OMITTAG NO was specified.
    <img src=http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/fiYou may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".
    site is www.cecilsrentarookie.co.uk if u need too view.

    thanks

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    PHP Code:
    <?php
    $url 
    "http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/";
    $monImage "$url"."fix-3.jpg";
    $tueImage "$url"."fix-3.jpg";
    $wedImage "$url"."fix-1.jpg";
    $thurImage "$url"."fix-2.jpg";
    $friImage "$url"."fix-2.jpg";
    $satImage "$url"."fix-2.jpg";
    $sunImage "$url"."fix-2.jpg";
    $d date("D");
    //Function that switches between date images based on the actual day of the week in $d
    switch ($d)
    {
    case 
    Mon:
    echo 
    '<img src="$monImage" alt="$monImage" />\n';
    break;
    case 
    Tue:
    echo 
    '<img src="$tueImage" alt="$tueImage" />\n';
    break;
    case 
    Wed:
    echo 
    '<img src="$wedImage" alt="$wedImage" />\n';
    break;
    case 
    Thu:
    echo 
    '<img src="$thurImage" alt="$thurImage" />\n';
    break;
    case 
    Fri:
    echo 
    '<img src="$friImage" alt="$friImage" />\n';
    break;
    case 
    Sat:
    echo 
    '<img src="$satImage" alt="$satImage" />\n';
    break;
    case 
    Sun:
    echo 
    '<img src="$sunImage" alt="$sunImage" />\n';
    }
    ?>
    That should validate correctly.

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, that doesn't work, it validates but now the images arent showing

  • #4
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Sorry about that:

    PHP Code:
    <?php
    $url 
    "http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/";
    $monImage "$url"."fix-3.jpg";
    $tueImage "$url"."fix-3.jpg";
    $wedImage "$url"."fix-1.jpg";
    $thurImage "$url"."fix-2.jpg";
    $friImage "$url"."fix-2.jpg";
    $satImage "$url"."fix-2.jpg";
    $sunImage "$url"."fix-2.jpg";
    $d date("D");
    //Function that switches between date images based on the actual day of the week in $d
    switch ($d)
    {
    case 
    Mon:
    echo 
    '<img src="'.$monImage.'" alt="'.$monImage.'" />\n';
    break;
    case 
    Tue:
    echo 
    '<img src="'.$tueImage.'" alt="'.$tueImage.'" />\n';
    break;
    case 
    Wed:
    echo 
    '<img src="'.$wedImage.'" alt="'.$wedImage.'" />\n';
    break;
    case 
    Thu:
    echo 
    '<img src="'.$thurImage.'" alt="'.$thurImage.'" />\n';
    break;
    case 
    Fri:
    echo 
    '<img src="'.$friImage.'" alt="'.$friImage.'" />\n';
    break;
    case 
    Sat:
    echo 
    '<img src="'.$satImage.'" alt="'.$satImage.'" />\n';
    break;
    case 
    Sun:
    echo 
    '<img src="'.$sunImage.'" alt="'.$sunImage.'" />\n';
    }
    ?>

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats ok bud, lol

    Erm, image now appears but I have the /n visble on page and the alt tage seems to pull in the url?

    Sorry bout this and thanks for helping me

  • #6
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    PHP Code:
    <?php
    $url 
    "http://www.cecilsrentarookie.co.uk/assets/images/spedeworth-fixtures/";
    $monImage "$url"."fix-3.jpg";
    $tueImage "$url"."fix-3.jpg";
    $wedImage "$url"."fix-1.jpg";
    $thurImage "$url"."fix-2.jpg";
    $friImage "$url"."fix-2.jpg";
    $satImage "$url"."fix-2.jpg";
    $sunImage "$url"."fix-2.jpg";
    $d date("D");
    //Function that switches between date images based on the actual day of the week in $d
    switch ($d)
    {
    case 
    Mon:
    echo 
    '<img src="'.$monImage.'" alt="'.$monImage.'" />';
    break;
    case 
    Tue:
    echo 
    '<img src="'.$tueImage.'" alt="'.$tueImage.'" />';
    break;
    case 
    Wed:
    echo 
    '<img src="'.$wedImage.'" alt="'.$wedImage.'" />';
    break;
    case 
    Thu:
    echo 
    '<img src="'.$thurImage.'" alt="'.$thurImage.'" />';
    break;
    case 
    Fri:
    echo 
    '<img src="'.$friImage.'" alt="'.$friImage.'" />';
    break;
    case 
    Sat:
    echo 
    '<img src="'.$satImage.'" alt="'.$satImage.'" />';
    break;
    case 
    Sun:
    echo 
    '<img src="'.$sunImage.'" alt="'.$sunImage.'" />';
    }
    ?>
    What do you mean by pull in the url?

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean by pull in the url?
    When you hover over the image, instead of displaying what is set as the alt tag, it displays the url instead

  • #8
    New Coder
    Join Date
    Jan 2006
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's ok, I have done it, simply renaming the alt tag worked, just looked different to the normal alt tags thats all.

    Thanks alot for your help, much appreciated


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •