I am having a small issue saving al POST fields into MongoDB
function savedata($data){
$collection = $this->db->retail_logs;
$this->data = json_decode($data);
try {
$collection->update(
array("tradingname"=>$this->data['tradingname']),
$this->data, "date"=> date("d.m.Y"), "time"=>date("H:i:s"),"whochanged"=>$_COOKIE['CRMUIDkey']), // new lead document to insert
array("upsert" => true, "safe" => true)
);
} catch (Exception $e) {
// Something went wrong ..
}
}
For some reson the $this->data which holds the $_POST does not want to go there i get this error
Warning: json_decode() expects parameter 1 to be string, array given in /home/crmvip/public_html/system/db/mongo.php on line 294
Warning: MongoCollection::update() expects at most 3 parameters, 4 given in /home/crmvip/public_html/system/db/mongo.php on line 302
it sends the POST information like it should tradingname=monkey&street=abc
json_decode is for decoding JSON.
If you just want to save value of
datareceived through a POST request: