Hi, My insert funcation is added below, as in php 5.6 i was able to post array data to database using below funcation but in php 7 it was not working i spend hours to find an solution but nothing is working.

Insert funcation

public function insert($table, $data) {

        $formattedVals = array();
        foreach (array_values($data) as $value) {
            $formattedVals[] = $this->_escapeString($value);
        }

        $sql = "INSERT INTO `" . $table . "`"
                . " (" . '`' . implode('`,`', array_keys($data)) . '`' . ")"
                . " VALUES (" . implode(",", $formattedVals) . ")";

        $result = mysqli_query($this->_con, $sql);
        return $result;
    }

My posting page is posting the array data to database as below

$data = array('fullname'=>$fullname,'address'=>$address,'image'=>$filename,'phone_1'=>$phone_1,'phone_2'=>$phone_2,'post_office'=>$pos,'pin_code'=>$pincode);
                $ins = $con->insert('customer', $data); 

I don't know what was the issue and why it was not posting, by the same way my other funcations like update, select, delet etc are not working in PHP VERSION 7 my update function also added below if any one can help please..

Update funcation

public function update($table, $data, $where) {

        $dataUpdate = array();
        foreach ($data as $field => $value) {
            $dataUpdate[] = "`" . $field . "` = " . $this->_escapeString($value);
        }

        if (is_array($where)) {
            $where = '(' . implode(') AND (', $where) . ')';
        }

        $sql = "UPDATE `" . $table . "` SET "
                . implode(',', $dataUpdate) . " WHERE " . $where;

        $result = mysqli_query($this->_con, $sql);
        return $result;
    }

Are you getting any notices or warnings in your error log? Temporarily use debug mode to write all php notices/warnings to the error log.

No error message no action is happening, and no error message.. On showing the message which we set for failed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.