Page 1 of 1

I can't figure this out - Parse error

Posted: Tue Aug 12, 2008 3:06 pm
by pakdamek
Hi..
I got this : [Parse error: parse error, unexpected $end in C:\AppServ\www\sisedocq\admin_viewall.php on line 317]

This is the source code :

Code: Select all

<?
include ('session.php');
$access_level = $_SESSION['access_level'];
 
if(isset($_GET['id']))
{
    @mysql_connect("localhost", "root", "1234") or die("Cannot connect to DB!");
    @mysql_select_db("sisedocq") or die("Cannot select DB!");
        $id      = $_GET['id'];
        $query   = "SELECT file_name, file_type, file_size,file_version, file_content,upload_date,upload_from,upload_verif_date,upload_verif_status,username,protect_type FROM document WHERE file_id = '$id' ";
        $result  = mysql_query($query) or die('Error, query failed');
        list($name, $type, $size,$version, $content,$upload_date,$upload_from,$upload_verif_date,$upload_verif_status,$username,$protect_type) = mysql_fetch_array($result);
        header("Content-Disposition: attachment; filename=$name");
        header("Content-length: $size");
        header("Content-type: $type");
        echo $content;
}
 
    $rows_per_page = 10;
    if(isset($_GET["page"])) $page = $_GET["page"];
                        else $page = 1;
    
    
    if(isset($_POST["keyword"])) $key = preg_replace("/'/", "\'", $_POST["keyword"]);
    else if(isset($_GET["keyword"])) $key = preg_replace("/'/", "\'", $_GET["keyword"]);
    else $key = "";
    
    $filter = "";
    $filter_i = 0;
    $order = "ORDER BY upload_date DESC";
    
    $f = ($rows_per_page*($page-1));
    $l = ($rows_per_page);
    
    $limit = "LIMIT $f, $l";
    
    if($key)
    {
        if(isset($_POST["search_by"])) $search_by = $_POST["search_by"];
        else if(isset($_GET["search_by"])) $search_by = $_GET["search_by"];
        else $search_by = "All";
        
        switch($search_by)
        {
            case 'All':
            $filter_arr[$filter_i++] = "("
                          ." file_id LIKE '%". $key ."%' OR"
                          ." file_name LIKE '%". $key ."%' OR "
                          ." file_content LIKE '%". $key ."%' OR "
                          ." category LIKE '%". $key ."%'"
                          .")";
            break;
            
            case 'Reference':
                $filter_arr[$filter_i++] = "(file_id LIKE '%". $key ."%')";
                break;
 
            case 'Category':
                $filter_arr[$filter_i++] = "(category LIKE '%". $key ."%')";
                break;
            
            case 'Title':
                $filter_arr[$filter_i++] = "(file_name LIKE '%". $key ."%')";
                break;
 
            case 'Date':
            list($day, $month, $year) = explode("/", $key);
            $datefrom = mktime(0,0,0,$month,$day,$year);
            $dateto = mktime(0,0,0,$month,$day+1,$year);
 
                $filter_arr[$filter_i++] = "(upload_date >". $datefrom ." AND upload_date <". $dateto .")";
                break;
            
            case 'Content':
                $filter_arr[$filter_i++] = "(file_content LIKE '%". $key ."%')";
                break;
            default:
                //die("undefined : ". $search_by);
        }
    }
    
    $filter_arr[$filter_i++]="upload_verif_status!='declined'";
    $filter_arr[$filter_i++]="upload_verif_status!='pending'";
    $filter_arr[$filter_i++]="document_status!='deletedR'";
    $filter_arr[$filter_i++]="document_status!='deleted'";
    $filter_arr[$filter_i++]="protect_type!='hidden'";
 
    $filter = "WHERE " . implode(" AND ",$filter_arr);
 
    @mysql_connect("localhost", "root", "1234") or die("Cannot connect to DB!");
    @mysql_select_db("sisedocq") or die("Cannot select DB!");
    
    $query  = "SELECT * FROM document"
            . " $filter";
            
    $result  = mysql_query($query) or die('Error : '. mysql_error());
    $total_result = mysql_num_rows($result);
    $total_pages = ceil($total_result/$rows_per_page);
    
    $query  = "SELECT * FROM document"
            . " $filter"
            . " $order"
            . " $limit";
        
    // debug    
    //echo "$query"
    //    ."<br>Total : " . mysql_num_rows($result);
    $result  = mysql_query($query) or die('Error : '. mysql_error());
    $total_result_per_page = mysql_num_rows($result);
    if($total_result_per_page<$rows_per_page)
    {$total_result_per_page=$total_result;}
    else
    {$total_result_per_page=mysql_num_rows($result)*$page;}
 
    $query_pending  = "SELECT * FROM document"
                    . " WHERE username='$username' AND upload_verif_status='pending'";
 
        $result_pending  = mysql_query($query_pending) or die('Error : '. mysql_error());
          $pending=mysql_num_rows($result_pending);
          
  function  getUserList()
  {
          $username=$_SESSION['username'];
           $str_query = "SELECT username FROM user WHERE username != '$username'";
           $result=mysql_query($str_query);
 
           if(mysql_num_rows($result)>0)
           {
           ?>
 
           <select name="username2" >
           <?
           while($row=mysql_fetch_array($result))
                 {
                      ?>
                        <option>
                                <? echo $row["username"]; ?>
                        </option>
                      <?
                 }
            ?>
            </select>
            <?
 
            }
  }
          
?>
<html>
<head>
<title>View All </title>
<? include ("real_login-header.html");
if($access_level=="Admin"){include ("admin_menu.html");}
else{include ("staff_menu.html");}
  ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
                function selectAll()
                {
                    if(document.admin.sel_all.checked==true)
                        for(i=0;document.admin["chk_"+i] ;i++)
                            document.admin["chk_"+i].checked = true;
                    else
                        for(i=0;document.admin["chk_"+i] ;i++)
                            document.admin["chk_"+i].checked = false;
                }
                
                function delSelected()
                {
                    chkChecked = false;
                            for(i=0;document.admin["chk_"+i] ;i++)
                            {
                                    if(document.admin["chk_"+i].checked == true)
                                    {
                                    chkChecked =true;
                                    break;
                                    }
                            }
                                if(chkChecked == true)
                                {
                                    if(confirm("Are you sure?"))
                                    {
                                      document.admin.action="delete_file.php";
                                      document.admin.submit();
                                     }
                                } 
                }
</script>
<script language="javascript" src="cal2.js">
</script>
<script language="javascript" src="cal_conf2.js"></script>
  <SCRIPT language="JavaScript">
 
          function setDropDown(drpDown, val1){
 
                  for(i=0;i<drpDown.length;i++)
                          {
                                    if(drpDown[i].value==val1) //for NS use options command to get the value
                                     {
                                       drpDown.selectedIndex = i;
                                    }
                           }
          }
function popup(url)
{
    newwindow=window.open(url,'name','height=196,width=301,scrollbars=yes, left=300, top=200');
    if (window.focus) {newwindow.focus()}
    return false;
}  
                  </script>
 
<link href="sddm.css" rel="stylesheet" type="text/css">
</head>
<body width="1024">
<div align="center">
<form action="admin_viewall.php" method="post" name="admin">
  <!-- main table starts here-->
  <div align="center">
      <table width="1024" align="left" dwcopytype="CopyTableCell">
        <tr valign="top"> 
          <p>
          <td  width="10%" height="42"><font color="#000099" size="3" face="Impact">VIEW 
            ALL </font></td>
          </p>
          <td width="69%"><div align="center"> 
            <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">SEARCH:</font> 
              <font size="2" face="Arial, Helvetica, sans-serif">
              <input type="text" name="keyword" value="<?= $key ?>">
              &nbsp;BY: 
              <select name="search_by">
                <option>All</option>
                <option>Reference</option>
                <option>Category</option>
                <option>Title</option>
                <option>Content</option>
                <option>Date</option>
              </select>
              &nbsp;</font> 
              <!--
              <font face="Courier New, Courier, mono">Owner</font><font face="Courier New, Courier, mono"> 
       :<?getUserList(); //username2
            ?>
        </font> -->
              <script> setDropDown(document.admin.search_by,"<? echo $_POST["search_by"]; ?>"); </script>
              <small><span title="Calendar"><a href="javascript&#058;showCal('Calendar1')"><img src="images/icon/calendar.gif" border="0" align="bottom"></a></span></small> 
              <input type="submit" name="Submit" value="go">
              &nbsp;<span title="View All"><a href="admin_viewall.php"><img src="images/icon/all.gif" border="0" align="absbottom"></a></span></font></div></td>
          <td width="21%"> 
            <div align="center">
     <?
        if($key) $add_key = "&keyword=$key&search_by=$search_by";
        else $add_key = "";
        
    
     if($page!=1){
         ?><a href="admin_viewall.php?page=<?= $page-1 ?><?= $add_key ?>">
         <span title="Previous"><img src="images/icon/previouspage.gif" width="6" height="12" border=0></span>
         </a><?
      }
     ?>
     <?
     if($page != $total_pages && $total_pages>1){
         ?><a href="admin_viewall.php?page=<?= $page+1 ?><?= $add_key ?>">
        <span title="Next"><img src="images/icon/nextpage.gif" width="6" height="12" border=0></span>
         </a><?
      }
     ?>
     
     
     </div></td>
      </tr>
      <!-- this is where the info table starts -->
      <tr> 
        <td colspan="4"> <div align="center"> 
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1"  bgcolor="#000000" >
                <tr bgcolor="#F8EFB2"> 
                  <th width="9%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><span title="Reference number">Ref</span></font></div></th>
                  <th width="32%"> <div align="left"><font size="2" face="Arial, Helvetica, sans-serif">&nbsp; 
                      File</font></div></th>
                  <th width="3%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"><span title="Application">App</span></font></div></th>
                  <th width="4%"><div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Owner</font></div></th>
                  <th width="12%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Category</font></div></th>
                  <th width="8%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Type</font></div></th>
                  <th width="5%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Version</font></div></th>
                  <th width="10%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Date 
                      Uploaded</font></div></th>
                  <th width="6%"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">Action</font></div></th>
                  <?
$count=-1;
while($row = mysql_fetch_array($result))
{
$count++;
 
?>
                <tr bgcolor="#FBF7D7"> 
                  <td> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"> 
                      <? echo date("Ym",$row["upload_date"]);
            $id=$row["file_id"];
            if($id%10==$id)
            {echo "000",    $id;}
            else if($id%100==$id)
            {echo "00", $id;}
            else if($id%1000==$id)
            {echo "0",  $id;}
            else if($id%10000==$id)
            {echo $id;}
             ?> </font></div></td>
                  <td> <font size="2" face="Arial, Helvetica, sans-serif"> <SPAN TITLE="<? echo  $row["description"],"(";
                                    echo $row["file_type"],")"; ?>"> <span title="Properties">&nbsp;&nbsp; 
                    <a href='viewall_properties.php?file_id=<? echo $row["file_id"]; ?> ' onClick="return popup('viewall_properties.php?file_id=<? echo $row["file_id"]; ?> ')"><img src="images/icon/properties.gif" width="14" height="14" border="0"></span></a> 
                    <?
                  $data= $row["file_name"];
                  list($file, $ext) = explode(".", $data);
                  echo $file; 
                  
         ?>
                 
Thank you.

Re: I can't figure this out - Parse error

Posted: Tue Aug 12, 2008 3:12 pm
by xitura
It looks like you are missing the ending } from the while-loop started at line 290.