我有一个名为CHCID的类,里面有两个函数:
public function UpdateDeliveryAddress($orderNumber, $deliveryaddress) {
$sql = "UPDATE `CIDOrders`
SET `DeliveryAddress` = '" . mysql_real_escape_string($deliveryaddress) . "'
WHERE `CIDOrderNumber` = " . $orderNumber . ";";
mysql_select_db(DB_DATABASE_NAME, $this->conn);
return mysql_query($sql, $this->conn);
}
public function UpdateInvoiceAddress($orderNumber, $invoiceAddress) {
$sql = "UPDATE `CIDOrders`
SET `InvoiceAddress` = '" . mysql_real_escape_string($invoiceaddress) . "'
WHERE `CIDOrderNumber` = " . $orderNumber . ";";
mysql_select_db(DB_DATABASE_NAME, $this->conn);
return mysql_query($sql, $this->conn);
}
我在名为createorder.php的页面中调用此类,如下所示:
// Add a new delivery address to the order
$cid->UpdateDeliveryAddress($_POST['orderNumber'], $_POST['deliveryaddress']);
// Add invoice address to the order
$cid->UpdateInvoiceAddress($_POST['orderNumber'], $_POST['invoiceaddress']);
我收到以下错误:
PHP Fatal error: Call to undefined method CHCID::UpdateDeliveryAddress()
任何人都可以提供帮助。
非常感谢
代码初始化类。
require_once $CID_INCLUDE_PATH . "/cid.php";
$cid = new CHCID();
构建类
class CHCID {
var $conn;
// Constructor, connect to the database
public function __construct() {
require_once "/var/www/reporting/settings.php";
if(!$this->conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) die(mysql_error());
if(!mysql_select_db(DB_DATABASE_NAME, $this->conn)) die(mysql_error());
}
答案 0 :(得分:0)
如果这些功能真的在你的课堂上,那么这种情况永远不会发生。
检查$CID_INCLUDE_PATH
,你可能正在加载一个不同的文件,也许是该类的旧版本。同时启用警告,通知......