开发者

call to undefined method php error

开发者 https://www.devze.com 2023-04-08 04:50 出处:网络
I have a class called CHCID which has the two functions inside it: public function UpdateDeliveryAddress($orderNumber, $deliveryaddress) {

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

public function UpdateDeliveryAddress($orderNumber, $deliveryaddress) {

    $sql = "UPDATE `CIDOrders`

    SET `DeliveryAddress` = '" . m开发者_如何学JAVAysql_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());

    }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消