Hey im having issues inserting an element into an existing mongodb document. At the moment there is an array containing a single element in my db :
$count = array();
array_push($count, 0);
$dbase->insert(array("_id"=> $_id,"count"=>$count));
However i now wish to insert a single element back into the "count array" and after looking around this was the recommended way:
$count=4;
$dbase->update(array('_id'=>'57b35f7bce23505c10000029'),array('$count'=>$count));
However this is throwing an error (error 500, internal server error) and im unsure why. Iv also tried using insert but it results in the creation of a new document. Any help would be appreciated.
$countwith the value of the PHP variable$count... this will not work as you are expecting, see my answer below.