PHP:从另一个函数500内部服务器错误调用函数时出错

时间:2012-09-06 21:12:31

标签: php function

从其他函数调用函数时,我没有发现错误:

功能PHP

class DB_Functions extends DB_Connect{

    private $dbConnect = "";

    public function __construct() {
        $this->dbConnect = $this->pdo_connect();
    }

    public function __destruct() {
        $this->dbConnect = null;
    }

    public function actionOnProfile() {

        //MORE CODE
        $id = $this->dataActionProfile['id'];
        $nombre = $this->dataActionProfile['nombre'];
        $descrip = $this->dataActionProfile['descrip'];

        updateprofile($nombre, $descrip, $id);
    }

    function updateprofile($nombre, $descrip, $id) {
        $sql = "UPDATE cat_perfiles SET Nombre = :nom, Descripcion = :des WHERE Id = :id";

        $result = $this->dbConnect->prepare($sql) or die ($sql);
        $result->bindParam(':nom',$nombre,PDO::PARAM_STR);
        $result->bindParam(':des',$descrip,PDO::PARAM_STR);
        $result->bindParam(':id',$id,PDO::PARAM_INT);

        if (!$result->execute()) {
            return false; 
        }

        $jsonErrorProfile = array();
        $jsonErrorProfile['success'] = 'success';
        return $jsonErrorProfile;
    }
}

错误是指使用 updateprofile($ nombre,$ descrip,$ id);

错误: 500内部服务器错误

1 个答案:

答案 0 :(得分:2)

因为您需要致电$this->updateprofile(...);

在PHP中,除了C ++,C#,Java等之外 - 你需要始终指定$this->

相关问题