}
    if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    } else {
        if (file_exists($newFileName)) {
            echo $title . " already exists. ";
        } else {
            move_uploaded_file($_FILES["file"]["tmp_name"], $newFileName);
            chmod($newFileName, 0755);
            require 'mysql.php';
            require 'printDL.php';
            $sql = "INSERT INTO descriptions (`number`, filename, title, description, dir, parashah, ultime)\nVALUES\n('" . mysql_real_escape_string($number) . "', \n '" . mysql_real_escape_string($baseFileName) . "', \n'" . mysql_real_escape_string($title) . "', \n'" . mysql_real_escape_string($description) . "', \n'" . mysql_real_escape_string($directory) . "', \n'" . mysql_real_escape_string($parashah) . "', \nCURDATE())";
            mysql_query($sql, $con);
            mysql_close($con);
            echo $baseFileName . ' has been uploaded.';
            printNewHeadline('Preview');
            printShiur($title, $baseFileName, $description, $directory);
            //echo '<h3>Description:</h3><br />'.$description;
        }
    }
} else {
    //if (empty($_POST['parashah']) ) echo 'You Must Select a Parashah';
    if (empty($_POST['title'])) {
        echo 'You Must Enter a Title';
    }
}
?>

 <div class="grid_1"><p></p></div>
 
</div>
function ListByParashah($parashah)
{
    $parashah = str_replace("\\", "", $parashah);
    $parashah = trim($parashah);
    //
    require 'mysql.php';
    $result = mysql_query("SELECT filename, title, description, dir \n\t\t\t\t\t\t\tFROM descriptions \n\t\t\t\t\t\t\tWHERE parashah='" . mysql_real_escape_string($parashah) . "' \n\t\t\t\t\t\t\tORDER BY `dir` DESC, `filename` ASC");
    mysql_close($con);
    //store shiurim in array
    $n = 0;
    while ($row = mysql_fetch_array($result)) {
        $shiurim['title'][$n] = $row['title'];
        $shiurim['filename'][$n] = $row['filename'];
        $shiurim['dir'][$n] = $row['dir'];
        $shiurim['description'][$n] = $row['description'];
        if (strcmp($shiurim['dir'][$n], 'mp3/') == 0) {
            $shiurim['date'][$n] = '(2004 - 2007)';
        } else {
            if (strcmp($shiurim['dir'][$n], 'mp3/NC/') == 0) {
                $shiurim['date'][$n] = '(2012)';
            }
        }
        $n++;
    }
    //print out shiurim according to series
    $currentSeries = $shiurim['dir'][0];
    printHeadline('Classes for Parashas ' . $parashah . ' ' . $shiurim['date'][0]);
    for ($i = 0; $i < sizeof($shiurim['dir']); $i++) {
        if ($shiurim['dir'][$i] != $currentSeries) {
            $currentSeries = $shiurim['dir'][$i];
            printNewHeadline('Classes for Parashas ' . $parashah . ' ' . $shiurim['date'][$i]);
        }
        printShiur($shiurim['title'][$i], $shiurim['filename'][$i], $shiurim['description'][$i], $shiurim['dir'][$i]);
    }
    //echo '<br />';
}
        $sql = "UPDATE descriptions \n\t\tSET title='" . mysql_real_escape_string($title) . "',\n\t\tfilename='" . mysql_real_escape_string($new_filename) . "',  \n\t\tdescription='" . mysql_real_escape_string($description) . "' \n\t\tWHERE filename='" . mysql_real_escape_string($filename) . "'";
        mysql_query($sql, $con);
        rename($old_path, $new_path);
        //echo   'The title of '.$filename.' has been updated to: <b>'.$new_filename.'</b><br />';
        printHeadline('Preview');
        printShiur($title, $new_filename, $description, $dir);
        printNewHeadline('Do Another Shiur');
    } else {
        echo 'Sorry the file ' . $new_filename . ' already exists.  Please choose a different name.';
    }
} else {
    $sql = "UPDATE descriptions \n\tSET description='" . mysql_real_escape_string($description) . "' \n\tWHERE filename='" . mysql_real_escape_string($filename) . "'";
    mysql_query($sql, $con);
    printHeadline('Preview');
    printShiur($title, $new_filename, $description, $dir);
    printNewHeadline('Do Another Shiur');
}
?>
<form action="editdescription.php" method="post"
enctype="multipart/form-data">
      <table>
      <tr>
  <td>Chumash/Series:</td>
  <td><select name="chumash" id="chumash" onchange="getParashah()" >
        <option value="Bereishit">Bereishit</option>
        <option value="Shemot">Shemot</option>
        <option value="Vayikra">Vayikra</option>
        <option value="Bamidbar">Bamidbar</option>
        <option value="Devarim">Devarim</option>
        <option value="Davening">Davening</option>
        <option value="Tehillim">Tehillim</option>