Script won't validate -- please help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi everyone,

I've got an assignment due in a couple hours and I can't get the darn
thing to validate. Am I overlooking something obvious? I sure would
appreciate help if anyone has time.

Here's the source code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    " ">
     <html xmlns=" " xml:lang="en" lang="en">
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <link rel="stylesheet" type="text/css" />
     <title>Ecards R Us</title>


<a href="?dir=anna_may_wong">Anna May Wong</a><br />

    $aimage_dir = dirname(__FILE__) . '/../../../images/';
    $ecard_dir = 'anna_may_wong/';
    $url_dir = 'anna_may_wong';
    if(isset($_GET['dir'])) {
       $url_dir = $_GET['dir'];
       $ecard_dir = $_GET['dir'] .'/';
    $adir = $aimage_dir . $ecard_dir; // absolute path, use for OS calls
    $rdir = '/~dgoodi01/images/' . $ecard_dir; // relative path use for
HTML output

     $full_sized = "";
     if(isset($_GET['img'])) {
        $full_sized = "<img src='$rdir/fullsize/".$_GET['img'].'' />';
     $images = array();
     if($dh = opendir($adir.'thumbs')) {
        // read the files with readdir($dh);
        while($file = readdir($dh)) {
            // we don't want directories: ., .., .DS_Store, thumbs
            // our script is in /users/dputnam/public_html/php
            if(is_dir($adir.'thumbs/'.$file)) { continue; }
            if(strstr($file,'.jpg')) {
                if(file_exists($adir.'thumbs/'.$file)) {
                     $images[] = $file;

     // We have an array that contains all of the images.
     // $images has all images in it.
     // We want a random selection.
     // Fortunately, we have array_rand(ANARRAY, number)
     $num = 16;
     // array_rand returns the index numbers
     $indexes = array_rand($images, $num);


     $for_view = '';
     foreach($indexes as $idx) {
         $for_view .= "<a
href=\"?v=ecards&dir=$url_dir&img=\"><img src=\"
         $rdir/thumbs/\" width=\"90\" /></a>";
     print $for_view;
     print $full_sized;


Re: Script won't validate -- please help

me wrote:
Quoted text here. Click to load it

< snip>

Explain 'validate'.

Do you mean html validation?

Is the code working as needed?


Re: Script won't validate -- please help

me escribió:
Quoted text here. Click to load it

Alright... PHP can be parsed successfully or not. It can trigger errors,
warnings or notices, or not. But there isn't such concept as "validate":
it's a programming language, not a markup language.

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Site Timeline