简体   繁体   中英

call to undefined method php error

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

    }

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM