PHP Mongodb - POST array insert -


i trying convert post data format allow me pass right collection. example: when print_r on $_post form data:

array (     [name] => steve     [email] => steve@mail.com     [submit] => submit ) 

i wondering how can convert acceptable object insert mongodb collection using php similar to:

$record = array(     'name' => 'steve',     'email' => 'steve@mail.com',     'submit' => 'submit' ); $collection->insert($record); 

i thinking loop of above array additional formatting can't seem figure out. have tried json_encode keep getting same error "call member function insert() on non-object in..." saying not proper object. thank help.

no need encode anything, it's php native , expects array. let driver work you:

$collection->insert( $_post ); 

as 2 should equivalant:

$rec = array(   'name' => 'steve',   'email' => 'steve@mail.com',   'submit' => 'submit' );  print_r ($rec); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -