2011-09-21 90 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