douqiao3453
2011-09-28 18:43
浏览 37
已采纳

调用未定义的方法php错误

I have a class called CHCID which has the two functions inside it:

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

}

I call this class in a page called createorder.php as follow:

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

I get the following error :

PHP Fatal error:  Call to undefined method CHCID::UpdateDeliveryAddress() 

Can anyone help.

Many thanks

Code initialising the class.

require_once $CID_INCLUDE_PATH . "/cid.php";

$cid = new CHCID();

Constructing class

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

    }
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpcnm2132 2011-09-28 19:23
    已采纳

    If those function were really in your class, this would never happen.

    Check $CID_INCLUDE_PATH, you're probably loading a different file, maybe an older version of the class. Also enable warnings, notices...

    打赏 评论

相关推荐 更多相似问题