views:

107

answers:

2

I am getting the following error when i upload the file to my host server. Same thing works fine in my machine running xampp

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home1/mobyhold/public_html/admin-arabiadc/admin/_product.php on line 1

<?
include "../include/manager_shared.php";
if(isset($_REQUEST['submit']))
{

############### image upload start ###########
    if ($PhotoT == "Change_Photo" || $PhotoT == "")
    {
          $Picc = $HTTP_POST_FILES['product_image']['name'];
          $size_limit = "204800"; /* set size limit in bytes - 200kb*/
          $allowed_types = array("image/gif","image/jpeg", "image/pjpeg", "image/jpg", "image/bmp", "image/png", "image/x-png", "image/psd");
          /*NB: DON'T change the types allowed coz these are the ones that GetImageSize() can handle*/
          $maxPixelSize = 1000;

          if(!empty($Picc))
          {
              $img_size=$HTTP_POST_FILES['product_image']['size'];
              $img_type=$HTTP_POST_FILES['product_image']['type'];
              $temp = $HTTP_POST_FILES['product_image']['tmp_name'];
              $size_limit = "2048000"; /* set size limit in bytes - 200kb*/
              $allowed_types = array("image/gif","image/jpeg", "image/pjpeg", "image/jpg");

              /*NB: DON'T change the types allowed coz these are the ones that GetImageSize() can handle*/
              $maxPixelSize = 1500;
              if($img_size!="0")
              {
                  if ($img_size < $size_limit)
                  {
                     if (in_array($img_type,$allowed_types))
                     {
                        $pixelsize = getimagesize($temp);
                        if(($pixelsize[0]>$maxPixelSize) || ($pixelsize[1]>$maxPixelSize))
                        {
                             $err_msgs .= "The file <span class=red>$Picc</span> you selected is <B style='color:#FFFFFF'>$pixelsize[0] X 
$pixelsize[1]</b> pixels and is too large to be uploaded!<br>";
                        }
                     }
                     else
                     {
                        $err_msgs .= "The file <span class=red>$Picc</span> is not an image. Files of type 
<B style='color:#FFFFFF'>$img_type</b> are not allowed to be uploaded!<br>";
                     }
                  }
                  else
                  {
                       $err_msgs .= "The file <span class=red>$Picc</span> you selected to upload is too large to be 
uploaded!<br>";
                  }
              } 
              else if($img_size=="0")
              {
                  $err_msgs .= "The file <span class=red>$Picc</span> was not found!<br>";
              }
          }
                    /* if ($PhotoT == "Change_Photo" && empty($Picc))
                     {
                          $err_msgs .= "No image uploaded!<br>";
                     } */
                    // else
                    //   $err_msgs .= "The file for <span class=red>Logo</span> is left empty.<br>";
    }
    if(!empty($err_msgs))   field_error($err_msgs, $sendtourl, $frm);
    $today_date = date("d/m/Y");
    if ($PhotoT == "Keep_Photo")
    {
        $Picc=$imghidden;
    }
    if ($PhotoT == "Remove_Photo")
    {
        $Picc="";
        if(!empty($imghidden))
        {
            $filep=$imghidden;
            unlink("../uploaded/".$filep);
        }
    }

    if ($PhotoT == "Change_Photo" || $PhotoT == "")
    {
                //imguploadstart
        $Picc = $HTTP_POST_FILES['product_image']['name'];
        if(!empty($Picc))
        {
           $temp = $HTTP_POST_FILES['product_image']['tmp_name'];
           $uniq = uniqid("");
           $Picc = $uniq."_".$Picc;
           $upload  = "../uploaded/".$Picc;
           copy($temp, $upload);
           if(!empty($imghidden))
            {
                $filep=$imghidden;
                unlink("../uploaded/".$filep);
            }
         }
    }

    ########### image upload end   ########
    if(empty($product_id))
    {
    $sql_update_product = "insert product set
                                `product_name`='$product_name',
                                `category_id`='$category_id',
                                `menu_id`=0,
                                `product_brand`=0,
                                `product_image`='$Picc',
                                `short_desc`='$short_desc',
                                `long_desc`='$long_desc',
                                `bussiness_address`='".$_REQUEST['bussiness_address']."',
                                `item_number`='$item_number',
                                `price`=0.00,
                                `discounts`=0,
                                `discount_type`='I',
                                `weight`=0.00,
                                `available`='Y',
                                `featured`='Y',

                                `isactive`=1,
                                `product_type`=1 ";

        $sql_update_product_qry = mysql_query($sql_update_product) or die(mysql_error());

        $today=date("Y-m-d H:i:s");
            if(!($sql_update_product_qry))
             $msgreport=3;
           else 
             $msgreport=4;
    }

    if(!empty($product_id))
    {

    $sql_update_product = "update product set
                                `product_name`='$product_name',
                                `category_id`='$category_id',
                                `menu_id`='$menu_id',
                                `product_brand`='$product_brand',
                                `product_image`='$Picc',
                                `short_desc`='$short_desc',
                                `long_desc`='$long_desc',
                                `bussiness_address`='".$_REQUEST['bussiness_address']."',
                                `item_number`='$item_number',
                                `price`='$price',
                                `discounts`='$discount_id',
                                `discount_type`='$discount_type',
                                `weight`='$weight',
                                `available`='$available',
                                `featured`='$featured',
                                `date_edit`='$today',
                                `isactive`='$status',
                                `product_type`='$type_available'
                                where product_id='$product_id' ";

        $sql_update_product_qry = mysql_query($sql_update_product) or die(mysql_error());

        $today=date("Y-m-d H:i:s");


        if(!($sql_update_product_qry)) 
             $msgreport=3;
           else 
             $msgreport=4;
    }

    echo "<script>window.location.href='catalog_product.php?selected_menu=2&messg=$msgreport';</script>";
}

if(!empty($product_id))
                {
            $sql_product = "select * from product where product_id = $product_id";

            $sql_product_qry = mysql_query($sql_product) or die(mysql_error());
            $sql_product_data = mysql_fetch_array($sql_product_qry);

            $product_name = $sql_product_data['product_name'];
            $category_id = $sql_product_data['category_id'];
            $menu_id=$sql_product_data['menu_id'];
            $subcategory_id = $sql_product_data['subcategory_id'];

            if(!empty($subcategory_id)) 
            { 
                $category_id = $subcategory_id;
            }
            $product_brand = $sql_product_data['product_brand'];
            $product_image = $sql_product_data['product_image'];
            $short_desc = $sql_product_data['short_desc'];
            $long_desc = $sql_product_data['long_desc'];
            $item_number = $sql_product_data['item_number'];
            $price = $sql_product_data['price'];
            $discounts = $sql_product_data['discounts'];
            $discount_type = $sql_product_data['discount_type'];
            $weight = $sql_product_data['weight'];
            $bussiness_address = $sql_product_data['bussiness_address'];
            $available = $sql_product_data['available'];
            $featured = $sql_product_data['featured'];
            $date_add = $sql_product_data['date_add'];
            $date_edit = $sql_product_data['date_edit'];
            $isactive = $sql_product_data['isactive'];
            $type_available = $sql_product_data['product_type'];
            $weight =  $sql_product_data['weight'];

            $a=0;

}
?>
<table width="100%" border="0" cellspacing="2" cellpadding="2">

  <tr>
    <td>
    <? ################################################################################## ?>
      <table width="100%" border="0" cellspacing="2" cellpadding="4">
        <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="product"  enctype="multipart/form-data">
          <input type="hidden" name="parent" value="<?=$category_id?>">
          <input type="hidden" name="product_id" value="<?=$product_id?>">

          <?
        if(!empty($errors)) {
        ?>
          <tr valign="middle"> 
            <td height="39" colspan="2" class="body"> The page encountered the 
              following errors:<br>
              <? echo $errors; ?> </td>
          </tr>
          <?
        }
        ?>
        <?
    if(!empty($msg)) {
        ?>

  <tr valign="middle"> 
    <td colspan="2"><? echo $msg; ?></td>
  </tr>
  <?
    }
    ?>
          <tr> 
            <td colspan="2" class="body">Fields marked with <span class="red">*</span> are 
              required</td>
          </tr>
          <tr> 
            <td width="30%" class="word">Bussiness 
              Name <span class="red">*</span></td>
            <td width="70%"><input name="product_name" type="text" value="<?=$product_name?>" class="formlist"></td>
          </tr>
          <tr> 
            <td width="30%" class="word">Select 
              Category <span class="red">*</span></td>
            <td width="70%"><select name="category_id" class="formlist">
              <option value=""> - </option>
              <?
               $sql_sel_parent_category = "select * from category where parent = '0' order by category_id";
             $sql_sel_parent_category_qry = mysql_query($sql_sel_parent_category) or die(mysql_error());
              while($sql_sel_parent_category_data = mysql_fetch_array($sql_sel_parent_category_qry))
                {

              ?>
              <option value="<?=$sql_sel_parent_category_data['category_id']?>"<?php 
if($sql_sel_parent_category_data['category_id']==$category_id){?>selected<?php }?>>
                <?=$sql_sel_parent_category_data['category_name']?>
                </option>
              <?
            ################ find sub category #####################
            $sql_sub = mysql_query("select * from category where parent = '$sql_sel_parent_category_data[category_id]'");
             $num = mysql_num_rows($sql_sub);
             if($num > 0)
                 {
                 while($sql_sub_data = mysql_fetch_array($sql_sub))
                     {
                     ?>
              <option value="<?=$sql_sub_data['category_id']?>"<?php 
        if($sql_sub_data['category_id']==$category_id){?>selected<?php }?>>..
                <?=$sql_sub_data['category_name']?>
                </option>
              <?
                    ################ find sub sub category #####################
                    $sql_subsub = mysql_query("select * from category where parent = '$sql_sub_data[category_id]'");
                     $num = mysql_num_rows($sql_sub);
                     if($num > 0)
                         {
                         while($sql_subsub_data = mysql_fetch_array($sql_subsub))
                             {
                             ?>
              <option value="<?=$sql_subsub_data['category_id']?>"<?php 
                if($sql_subsub_data['category_id']==$category_id){?>selected<?php }?>>....
                <?=$sql_subsub_data['category_name']?>
                </option>
              <?    
                    ################ find sub sub category #####################
                    $sql_subsubsub = mysql_query("select * from category where parent = '$sql_subsub_data[category_id]'");
                     $num = mysql_num_rows($sql_subsub);
                     if($num > 0)
                         {
                         while($sql_subsubsub_data = mysql_fetch_array($sql_subsubsub))
                             {
                             ?>
              <option value="<?=$sql_subsubsub_data['category_id']?>"<?php 
                if($sql_subsubsub_data['category_id']==$parent_category){?>selected<?php }?>>......
                <?=$sql_subsubsub_data['category_name']?>
                </option>
              <?    

                             }

                         }  

                             }

                         }
                     }
                 ?>
              <?
                }
            }
                ?>
            </select></td>
          </tr>
           <!--<tr> 
            <td width="30%" class="word">Select Item <span class="red">*</span></td>
            <td width="70%">
            <select name="menu_id" class="formlist">
            <option value=""> - </option>
               <?
             $sql_sel_parent_brand = "select * from main_menu WHERE isactive='Y'";
             $sql_sel_parent_brand_qry = mysql_query($sql_sel_parent_brand) or die(mysql_error());

              while($sql_sel_parent_brand_data = mysql_fetch_array($sql_sel_parent_brand_qry))
                {
              ?>
            <option value="<?=$sql_sel_parent_brand_data['menu_id']?>"<?php 
if($sql_sel_parent_brand_data['menu_id']==$menu_id){?>selected<?php }?>><?=$sql_sel_parent_brand_data['menuname']?></option>
            <?
                }
                ?>
            </select>           </td>
          </tr> -->
          <!--<tr> 
            <td width="30%" class="word">Bussiness 
              Brand <span class="red">*</span></td>
            <td width="70%">
            <select name="product_brand" class="formlist">
            <option value=""> - </option>
               <?
             $sql_sel_parent_brand = "select * from product_brand";
             $sql_sel_parent_brand_qry = mysql_query($sql_sel_parent_brand) or die(mysql_error());

              while($sql_sel_parent_brand_data = mysql_fetch_array($sql_sel_parent_brand_qry))
                {
              ?>
            <option value="<?=$sql_sel_parent_brand_data['brand_id']?>"<?php 
if($sql_sel_parent_brand_data['brand_id']==$product_brand){?>selected<?php }?>><?=$sql_sel_parent_brand_data['brand_name']?></option>
            <?
                }
                ?>
            </select>           </td>
          </tr> -->
          <tr> 
            <td width="30%" class="word">Bussiness 
              Image <span class="red">*</span></td>
            <td width="70%">
            <? 
    $SW = 75;
    $SH = 75;
    if (strlen($product_image)!=0)
    {
        $var="checked";

        $vpath = "../uploaded/".$product_image;
        $size = getimagesize($vpath);
        $Ht = $size[1];
        $Wdt = $size[0];
        if($Wdt <= $SW && $Ht <= $SH)
        {
            $ScW = $Wdt;
            $ScH = $Ht;
        }
        if($Wdt <= $SW && $Ht > $SH)
        {
            $ScH = $SH;
            $ScW = $Wdt - intval((($Ht - $SH)/$Ht)*$Wdt);
        }
        if($Wdt > $SW && $Ht <= $SH)
        {
            $ScW = $SW;
            $ScH = $Ht - intval((($Wdt - $SW)/$Wdt)*$Ht);
        }
        if($Wdt > $SW && $Ht > $SH)
        {
            if($Wdt==$Ht)
            {
                $ScW = $SW;
                $ScH = $SH;
            }
            else
            {
                if($Wdt!=$Ht)
                {
                    if($Wdt > $Ht)
                    {
                        $ScW = $SW;
                        $ScH = $Ht - intval((($Wdt - $SW)/$Wdt)*$Ht);
                    }
                    else
                    {
                        $ScH = $SH;
                        $ScW = $Wdt - intval((($Ht - $SH)/$Ht)*$Wdt);
                    }
                }//if($Wdt!=$Ht)
                else
                {
                    $ScW = $SW;
                    $ScH = $SH;
                }
            }//else of if($Wdt==$Ht)
        }
        ?>
        <img src="<? echo "../uploaded/$product_image"; ?>" height=<? echo $ScH ?> width="<? echo $ScW ?>"><BR> 
        <input type="radio" name="PhotoT" value="Keep_Photo" <? echo $var?> > <span class="body">Keep Image</span> 
        <input type="radio" name="PhotoT" value="Change_Photo"> <span class="body">Change Image</span>
        <br> 
        <?
    }
    ?>
        <INPUT type="file" name="product_image" class="formlist" size="50"> 
        <INPUT type="hidden" name="imghidden" value="<? echo $product_image; ?>">   </td>
          </tr>

          <tr> 
            <td width="30%" class="word">Webaddress <span class="red">*</span></td>
            <td width="70%"><textarea name="short_desc" cols="50" rows="4" class="formlist"><?=$short_desc?></textarea></td>
          </tr>
          <tr>
            <td class="word">Bussiness Address </td>
            <td><textarea name="bussiness_address" cols="50" rows="4" class="formlist"><?=$bussiness_address?></textarea></td>
          </tr>
          <tr> 
            <td width="30%" class="word"><p>google map hyperlink </p><!--<span class="red">*</span> --></td>
            <td width="70%"><textarea name="long_desc" cols="50" rows="4" class="formlist"><?=$long_desc?></textarea></td>
          </tr>
          <tr> 
                  <td align="left" valign="top" colspan="3">&nbsp;</td>
                </tr>
          <!--<tr> 
            <td width="30%" class="word">Bussiness Number <span class="red">*</span></td>
            <td width="70%"><input name="item_number" type="text" value="<?=$item_number?>" class="formlist"></td>
          </tr> -->
          <tr> 
            <td>&nbsp;</td>
            <td><input name="submit" type="submit" value="Submit" class="button" style="cursor:hand">
              &nbsp;
              <input name="submit" type="button" value="Back" onClick="javascript:history.back();" class="button" style="cursor:hand"></td>
          </tr>
        </form>
      </table>

    <? ################################################################################## ?>    </td>
  </tr>
</table>
A: 

Analyze line 1 of /home1/mobyhold/public_html/admin-arabiadc/admin/_product.php for mismatched or missing quotes.

Babiker
+1  A: 

Hmm. A parse error on line one? What's the "short_open_tag" setting on both servers?

(If you need to, use phpinfo() to find out what the server setting is; a test php file that's just got

<?php 
  phpinfo(); 
?>

...in it will do the trick.)

Matt Gibson