2016-12-17 127 views
0

我面臨一個問題,不知道這是服務器問題還是我的編碼。問題是,當我在數據庫中進行一些更改(插入,更新,刪除)以及上傳圖像時,我得到一個錯誤,說[sitename]目前無法處理此請求。但是,如果我做任何交易沒有圖像上傳一切順利。服務器當前無法處理此請求

但還有另一件事,因爲我很困惑的是,我的網站也有一個管理面板,如果我上傳的圖像和數據從用戶端每件事情的作品,但如果我上傳數據與圖像給出了一個錯誤。不知道問題出在哪裏。無論是在服務器端問題還是在我的代碼中。?

以下是用戶端正在使用的代碼。

public function partner_register() { 

     $date = date('Y/m/d'); 
     $this -> form_validation -> set_rules('contact', 'person contact', 'required|xss_clean'); 
     $this -> form_validation -> set_rules('company', 'company name', 'required|xss_clean'); 
     $this -> form_validation -> set_rules('ph', 'phone', 'required|xss_clean'); 
     $this -> form_validation -> set_rules('email', 'email', 'required|valid_email|is_unique[partner.email]|max_length[100]|xss_clean'); 

     $contact = $this -> input -> post('contact'); 
     $email = $this -> input -> post('email'); 
     $phone = $this -> input -> post('ph'); 
     $name = $this -> input -> post('company'); 
     $brand = $this -> input -> post('brand'); 

     if($brand == null or empty($brand) or $brand == "") { 
      ?> <script> alert('Select atleast one brand'); 
         window.location = "<?php echo base_url('register'); ?>"; 
       </script> 
      <?php 
     } 

     else if ($this -> form_validation -> run() == FALSE) { 
      ?> <script> alert('Email already exists. Please try new email.'); 
         window.location = "<?php echo base_url(); ?>"; 
       </script> 
      <?php 
     } 
     else { 
      $info = $this -> Parts_Model -> partner_register([ 
       'contact' => $contact, 
       'email'  => $email, 
       'company' => $name, 
       'phone'  => $phone, 
       'reg_date'  => $date, 
      ]); 
      if($info) { 
       foreach($brand as $key => $value) { 
        $brands = $this -> Parts_Model -> partner_brands([ 
         'partner_id' => $info, 
         'brands' => $value, 
        ]); 
       } 
       if($brands) { 
        ?> <script> alert('Subscription successfull.'); window.location = "<?php echo base_url('register'); ?>"; </script> <?php 
       } 
      } 
      else { 
       ?> <script> alert('Subscription failed.'); window.location = "<?php echo base_url('register'); ?>"; </script> <?php 
      } 
     } 
    } 

這裏是在後端使用的代碼,兩者幾乎都是相同的。

 public function add_ads() { 

     $this -> header_template(); 
     $this -> form_validation -> set_rules('link', 'ad link', 'required|xss_clean'); 
     $this -> form_validation -> set_rules('schedule', 'start date', 'required|xss_clean'); 
     $this -> form_validation -> set_rules('end_schedule', 'end date', 'required|xss_clean'); 

     $link = $this -> input -> post('link'); 
     $schedule = $this -> input -> post('schedule'); 
     $end_schedule = $this -> input -> post('end_schedule'); 

     $config['upload_path'] = 'ads/'; 
     $config['allowed_types'] = 'jpg|jpeg|png'; 
     $config['encrypt_name'] = true; 
     $this -> load -> library('upload', $config); 

     if($this -> form_validation -> run() == false) { 
      echo validation_errors(); 
     } 
     else { 
      if(!$this -> upload -> do_upload('ad')) { 
       ?> <script> alert('<?php echo $this -> upload -> display_errors(); ?>'); window.location = "<?php echo base_url('dashboard/ads'); ?>"; </script> <?php 
      } 
      else { 
       $data = $this -> upload -> data(); 
       if($data['file_name'] and $data['full_path']) { 
        $file_name = $data['file_name']; 
        $file_path = $config['upload_path'].$file_name; 
        $info = $this -> Dashboard_Model -> add_ads([ 
         'add_link'   => $link, 
         'schedule'   => $schedule, 
         'end_schedule'   => $end_schedule, 
         'ads'    => $file_path, 
        ]); 
        if($info) { 
        ?> 
         <script> alert('Added Successfully.'); window.location = "<?php echo base_url('dashboard/ads'); ?>"; </script> 
        <?php 
        } 
        else { 
         echo 'Error! While adding brands.'; 
        } 
       } 
      } 
     } 
    } 

這裏是服務器錯誤

Server Error Image

,這裏是服務器日誌錯誤

Log Errors

+0

似乎有一些內存限制問題和PHP的內存消耗超過它分配給。看看這個鏈接。 http://stackoverflow.com/questions/19508313/memory-limit-1024m-still-cannot-allocate-memory-couldnt-create-child-proce。 – Perumal

+0

什麼類型的內存磁盤存儲還是什麼? –

+0

我可以檢查它在哪個點上佔用大量內存 –

回答

0

基於錯誤日誌,它看起來像你的服務器資源無法處理您的請求了。

如果PHP的物理內存不足以處理您的腳本,那麼您的Web服務器無法產生新的子進程,從而遇到HTTP 500錯誤。

在這裏,如果您使用物理服務器,則需要查看物理內存。如果您正在VM中運行,請嘗試爲VM分配更多內存。

+0

他使用共享主機。除非他聯繫共享主機服務的管理員,否則他不能增加VM的物理內存。 – Perumal

+0

我檢查了我的內存使用情況,並向我展示了可用1.4 GB的0%使用情況,這意味着不存在內存使用問題。 –

+0

這不是關於分配給虛擬機的內存限制。這是關於分配給PHP的內存限制。做一件事。要知道分配給PHP的內存有多少,請編寫'echo ini_get('memory_limit');'並檢查頁面上打印的內容。一些共享的網絡託管服務提供商設置PHP的內存限制低於實際的'128M'。在你的情況,你的虛擬主機提供商可能已經把它設置得比'128M'低。編寫上面提到的代碼,並檢查它們分配給PHP內存消耗的分配量。 – Perumal

相關問題