Re: [PHP] mongo usage

[email protected] (Jonathan Sundquist)
Newsgroups php.general
Message-ID <CAJYze7mY_ai-vyygeWtXBLaRvvK4cQZVkZTAUTYOqUooC94WKw@mail.gmail.com>
You commented out the setting of yhe addresses variable
On Jul 6, 2013 1:42 PM, "Tim Dunphy" <[email protected]> wrote:

> Hey all,
>
>  I'm trying to pick up some basic use of MongoDB using PHP.
>
>  I seem to have hit an early obstacle that I'd like your opinion on. I try
> to pass an array to the mongo insert function, but for some reason the
> function does not recognize the array I'm passing. Even though I can
> perform a var_dump() on the array and see the contents.
>
> Here's the output I'm seeing (with error):
>
> Mongo Test Page array(6) { ["first_name"]=> string(5) "Peter"
> ["last_name"]=> string(6) "Parker" ["address"]=> string(16) "175 Fifth
> Avenue" ["city"]=> string(8) "New York" ["state"]=> string(2) "NY"
> ["zip"]=> string(5) "10010" }
>
> *Notice*: Undefined variable: addresses in */var/www/mongomaven/index.php*
> on
> line *36*
>
> *Fatal error*: Call to a member function insert() on a non-object in *
> /var/www/mongomaven/index.php* on line *36*
> *
> *
> And here's the code:
>
> <html>
>  <head>
>   <title>Mongo Test</title>
>  </head>
>  <body>
>
>  Mongo Test Page
>  <?php
>
>
>
>     $connection = new Mongo();
>
>
>     $db = $connection->jfdb;
>
>     $collection = $db->addresses;
>
>     //$adresses = $connection->jfdb->adresses;
>
>     $address = array(
>      'first_name' => 'Peter',
>     'last_name' => 'Parker',
>     'address' => '175 Fifth Avenue',
>     'city' => 'New York',
>     'state' => 'NY',
>     'zip' => '10010',    );
>
>     var_dump($address);
>
>     echo '<br />';
>
>    $addresses->insert($address);
>
>  ?>
>  </body>
> </html>
>
>
> I'd appreciate any advice you might have.
>
> Thanks,
> Tim
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.