缺少参数并修改标头信息错误

时间:2014-10-29 22:26:56

标签: php

如果有人能帮助我,我会感激不尽。 我收到了这个错误。

<b>Warning</b>:  Missing argument 1 for DonationSession::GetPaymentURL(), called in /home/desolutionrp/public_html/web/payment.php on line 18 and defined in <b>/public_html/web/inc/donate.class.php</b> on line <b>95</b><br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/desolutionrp/public_html/web/inc/donate.class.php:95) in <b>/public_html/web/payment.php</b> on line <b>18</b><br />

我检查了这些行上的内容,第一个错误就是这行:

function GetPaymentURL($email) {
   return "https://www." . (config_Sandbox ? "sandbox." : "") . "paypal.com/cgi-bin/webscr?on0=donationid&os0=" .$this->index . "&on1=steamid&os1=" . $this->steamid . "&cmd=_xclick&business=" . config_PayPalEmail . "&no_shipping=1&currency_code=USD&lc=EN&item_name=" . config_ProductName . "&amount=" . $this->value;
}

对于第二个错误,该行说:

header("Location:" . $donation->GetPaymentURL());

2 个答案:

答案 0 :(得分:0)

GetPaymentUrl()函数需要一个参数 - $email。调用该功能时,请确保您传递的是电子邮件地址。第二个错误 - “无法修改标题信息” - 是因为第一条错误消息已打印到屏幕上。一旦第一个错误得到修复,第二个错误就会消失。

答案 1 :(得分:0)

您的函数GetPaymentURL要求您传递$email

的参数

您可以通过3种方式处理此问题:

1)将默认值设为$email

function GetPaymentURL($email = '') {
    // return your data
}

2)删除$ email param,因为它似乎没有被使用

function GetPaymentURL() {
    // return your data
}

3)在函数调用中提供数据

header("Location:" . $donation->GetPaymentURL('emaiAddress@emailDomain.com'));

您的第二个问题可能是由于脚本将数据打印到屏幕上而导致的,可以使用输出缓冲来处理:

Cannot modify header information - headers already sent by... Wordpress Issue

有关此错误的更多信息:

How to fix "Headers already sent" error in PHP