解析错误:语法错误,PHP 中意外$end错误


Parse error: syntax error, unexpected $end error in PHP

我正在用php工作。我仅在服务器上遇到错误,而不是在本地主机中出现错误,错误是

Parse error: syntax error, unexpected $end.Some pages have error.

刷新页面时,未显示错误。我无法察觉到错误的原因。我尝试了很多次,但我无法检测到它。有人请帮助我...

我的页面add_sale.php我的代码是 - 错误部分

<?php
error_reporting(0);
require_once("codelibrary/inc/variables.php");
require_once("codelibrary/inc/functions.php");
 if(isset($_SESSION['sess_admin_id']))
 {
  if(!checkPermission('13'))
  {
   header("Location:noAction.php");
   }
 }
 else
 {
 header("Location:index.php");
 }
 validate_admin();
 @extract($_POST);
 $id=$_REQUEST['id'];
 $sql = "SELECT * FROM sale where id='$id'";
 $result = mysql_query($sql);
 $fet_cus=mysql_fetch_array($result);
 $cust_id=$fet_cus['cust_id'];
$sql2 = "SELECT * FROM receipt where sale_payment_id='$id'";
$result2 = mysql_query($sql2);
 $fet_cus2=mysql_fetch_array($result2);
  $cus="select * from customer where id='$cust_id'";
 $cus2=mysql_query($cus);
 $fet=mysql_fetch_array($cus2);
 $sales_person_id=$fet['sales_person_id'];
 $net_credit_db=$fet['credit_limit_net'];
 $credit_limit=$fet['credit_limit'];
 $opeing_balance=$fet['opeing_balance'];
 $opening_balance_type  =$fet['opening_balance_type']; 
 $sale="select * from admin where id='$sales_person_id'";
 $sale2=mysql_query($sale);
 $fet_sale=mysql_fetch_array($sale2);
 $digits = 4;
 $rand=rand(pow(10, $digits-1), pow(10, $digits)-1);
if($_POST['submit'])
{
$id =$_POST['id'];
$serial=$_POST['serial_number']; 
$cust_name=$_POST['cust_name']; 
$date=date("Y-m-d");
$sale_type=$_POST['sale_type'];
$sale_type3=$_POST['sale_type3'];
if($id=="")
{
$sale_type= $sale_type;
}
else
{
$sale_type= $sale_type3;    
}
//total
//$sale=$_POST['total_sale'];
$brand=$_POST['brand'];
$rate=$_POST['rate'];
$quantity=$_POST['quantity'];
if($sale_type=='credit')
{
$total_sale=$total;
}
if($sale_type=='payment')
{
$total_sale=$net_total; 
}

$sale_description=$_POST['sale_description'];
$credit_limit_last=$_POST['credit_limit_last'];
$country=$_POST['country2'];
$currency = $_POST['currency'];
$bank=$_POST['bank'];
$exchange_rate=$_POST['exchange_rate'];
$sql2 = "SELECT * FROM customer where id='$cust_name'";
$result2 = mysql_query($sql2);
$fet_cus2=mysql_fetch_array($result2);
$net_credit_db=$fet_cus2['credit_limit_net'];   
if($opening_balance_type=='Cr')
{
 if($net_credit_db=="" ||$net_credit_db==0)
  {
   $credit_limit_net=$credit_limit_last-$total;
  }
 else
  {
  $credit_limit_net=$net_credit_db-$total;      
   }
}
if($id=="")
{
    if($sale_type!='return')
      {

    $in="insert into    sale(serial,cust_id,date,brand,total,sale_type,
 sale_description,country,
  currency,bank,exchange_rate)       values('$serial','$cust_name','$date',
 '$brand','$total_sale','$sale_type','$sale_description',
 '$country','$currency','$bank','$exchange_rate')";
    $in2=mysql_query($in);
    $sale_id=mysql_insert_id();
    if($sale_type=='credit')
    {
    $up22="update customer set 
   credit_limit_net='$credit_limit_net' where id='$cust_name'";
    mysql_query($up22);
    }
    if($sale_type=='payment')
      {
        //end mail to bank  
        }

//mail to customer

//end mail to customer
//Mail to senior Accountant 
 //End Mail to senior Accountant    
     if($in2)
            {
                $sess_msg="Sale Added Successfully.";
            $_SESSION['sess_msg']=$sess_msg;
                 echo '<script type="text/javascript">alert("Sale Added Successfully");
                 window.location="add_sale.php";
                 </script>'; 
            }
      }
      else
      {
          //sales retun
       $in="insert into   sale(serial,cust_id,date,brand,total,
     sale_type,sale_description,country,
    currency,bank,exchange_rate)       values('$serial','$cust_name',
       '$date','$brand','$total',
    '$sale_type','$sale_description','$country','$currency','$bank','$exchange_rate')";
    mysql_query($in); 
     //sales retun from perticular row
        $re="select * from sale
    where cust_id='$cust_name' and total>='$total' and     (sale_type='credit'
 or sale_type='payment') limit 1";
       $re2=mysql_query($re);
       $num=mysql_num_rows($re2);
       if($num>0)
        {
          $fet= mysql_fetch_array($re2);
          $fet_id=$fet['id'];
          $fet_total=$fet['total'];
          $fet_net_total=$fet_total-$total;
          $up="update  sale set total='$fet_net_total' where id='$fet_id'";
          mysql_query($up);
        }
        else
        {
          $return="select * from sale where sale_type='credit' or sale_type='payment'";
          $return_qu=mysql_query($return);
          while(($fet=mysql_fetch_array($return_qu))&&($total>0))
          {
            $amount=$fet['total'];
            $total=$total-$amount;
            $fet_id=$fet['id'];
            if($total<0)
            {
            $total_negative=$total;
            $neg=-1;    
            $total_positive = $neg*$total_negative;
            $up="update  sale set total='$total_positive' where id='$fet_id'";
            mysql_query($up);   
            }
            else
            {
            $up="update  sale set total=0 where id='$fet_id'";
            mysql_query($up);
            }
          }
      }

      }

}
else
{

 $up="update sale set serial='$serial',date='$date',brand='$brand',
   total='$total',sale_description='$sale_description',
     country='$country',currency='$currency',
     bank='$bank',exchange_rate='$exchange_rate' where id='$id'";
   mysql_query($up);    
    if($sale_type=='credit')
    {
    $up22="update customer 
   set credit_limit_net='$credit_limit_net' where id='$cust_name'";
    mysql_query($up22);
    }
    if($sale_type=='payment')
      {

//send mail to senior accountant

 //End Mail to senior Ac
      }
}
}
?>

在这一部分中,您只是忘记了分号

$sql2 = "SELECT * FROM receipt where sale_payment_id='$id'";
$result2 = mysql_query($sql2);
$fet_cus2=mysql_fetch_array($result2);   <----- this one
$sql2 = "SELECT * FROM receipt where sale_payment_id='$id'";
$result2 = mysql_query($sql2);
$fet_cus2=mysql_fetch_array($result2);

$fet_cus2=mysql_fetch_array($result 2( 后缺少分号