缺少参数 &未定义的变量;错误的原因是什么?

发布于 2024-12-05 15:33:19 字数 1179 浏览 0 评论 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 有什么问题吗?

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??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟酉 2024-12-12 15:33:19

这意味着您没有在网址中传递所需数量的段

/welcome/quote/product_id

您似乎在请求:

/欢迎/引用

如果您希望能够在没有错误的情况下访问后者,请给它一个默认值:

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

然后您可以执行以下操作:

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

但是,如果您传递了所需数量的段,请更新问题以包含您的内容/config/routes.php 文件(假设您已编辑它)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文