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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?