问题描述:

I am receiving the following errors, I'm asking if anyone knows a possible reason why I would get these. I am newbish so help would be grateful...

I will also post the lines in question.

A PHP Error was encountered

Severity: Warning

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

Filename: controllers/welcome.php

Line Number: 64

and

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: productid

Filename: controllers/welcome.php

Line Number: 65

The lines in question;

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');

.. }

.. }

.. }

what's wrong with $productid??

网友答案:

It means you're not passing the required amount of segments in your URL

/welcome/quote/product_id

It seems you're requesting:

/welcome/quote

If you want to be able to access the latter without an error, give it a default value:

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

and then you can do:

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

If you are passing the required amount of segments however, update the question to include the contents of your /config/routes.php file (assuming you've edited it).

相关阅读:
Top