2011-09-21 89 views
0

我收到以下錯誤,我詢問是否有人知道我爲什麼會得到這些錯誤的可能原因。我是新手,所以幫助將不勝感激... 我也將張貼有問題的路線。缺少參數和未定義的變量;錯誤的原因是什麼?

A PHP Error was encountered 

Severity: Warning 

Message: Missing argument 1 for Welcome::quote() 

Filename: controllers/welcome.php 

Line Number: 64 

A PHP Error was encountered 

Severity: Notice 

Message: Undefined variable: productid 

Filename: controllers/welcome.php 

Line Number: 65 

在考慮中的線;

64 function quote($productid){ 
65  if ($productid > 0){ 
66   $fullproduct = $this->MProducts->getProduct($productid); 
67   $this->MQuotes->updateQuote($productid,$fullproduct); 
68   redirect('welcome/product/'.$productid, 'refresh'); 
69  }else{ 
70  $data['title'] = '... | Quote'; 
..  
..  if (count($_SESSION['quote']) == true){ 
..  $data['main'] = 'quote'; 
..  $data['navlist'] = $this->MCats->getCategoriesNav(); 
..  $this->load->vars($data); 
..  $this->load->view('template'); 
..  }else{ 
..  redirect('welcome/index','refresh'); 
..  } 
.. } 
.. } 

$ productid有什麼問題?

+0

這可能不是函數的問題,但你是如何調用它的。 –

回答

2

這意味着你沒有通過所需段的量在您的網址

/首頁/報價/ PRODUCT_ID

看來你的要求:

/welcome/quote

如果你想成爲能夠訪問後者沒有錯誤,給它一個默認值:

function quote($productid = -1){ 
    // 
} 

,然後你可以這樣做:

function quote($productid = null){ 
    if (is_null($productid)) { 
     // one workflow 
    } else { 
     // another workflow 
    } 
} 

但是,如果將此傳遞所需段的量,更新問題包括你的/config/routes.php文件的內容(假設你已經編輯它)。

+0

一個簡單的情況下加=空...親愛的我,我越來越多地學習每一天。非常感謝兄弟 – Jon