php-general Digest 6 Jul 2013 19:14:09 -0000 Issue 8287
Topics (messages 321559 through 321565):
Re: strlen ?
321559 by: Jim Giner
321560 by: Lester Caine
mongo usage
321561 by: Tim Dunphy
321563 by: Thomas Punt
321564 by: Jonathan Sundquist
321565 by: Tim Dunphy
Guaranteed Way to Get Error Message Wanted
321562 by: Brian Smither
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 7/6/2013 2:59 AM, Lester Caine wrote:
Jim Giner wrote:
And the answer is - yes, there is a LF char at the end of my data in
my whole
table.
Now the question is - how the heck did I put that in there? Certainly
not
intentionally. The data is captured from a d/e screen I wrote and it
simply
grabs the post value and inserts a new record with that value along
with some
other values. And I don't see anything concatenating a LF to my string.
The obvious question that comes to mind is 'What OS'? Having seen this
sort of niggle many times I tend to find it relates to something working
'cross-os' a bit like windows ignoring case in file name and linux then
complaining it can't find a file.
It's probably worth checking the sting length back through your code
just to confirm what added it?
The best I can figure is that I did a preload of many of the names from
a csv file. Apparently when I do that it stores the LF at the end of
the csv line. Have to remember that the next time.
--- End Message ---
--- Begin Message ---
Jim Giner wrote:
It's probably worth checking the sting length back through your code
just to confirm what added it?
The best I can figure is that I did a preload of many of the names from a csv
file. Apparently when I do that it stores the LF at the end of the csv line.
Have to remember that the next time.
AH - I use that to flag the end of line when I pulled the data apart - so it
gets stripped ;)
Then I found fgetcsv() which replaced the manual code and gave just the data as
an array.
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Could the comma after the last element in your array be causing the problem?
> Date: Sat, 6 Jul 2013 14:42:07 -0400
> From: bluethu...@gmail.com
> To: php-gene...@lists.php.net
> Subject: [PHP] mongo usage
>
> 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
--- End Message ---
--- Begin Message ---
You commented out the setting of yhe addresses variable
On Jul 6, 2013 1:42 PM, "Tim Dunphy" <bluethu...@gmail.com> 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
>
--- End Message ---
--- Begin Message ---
| Could the comma after the last element in your array be causing the
problem?
I tried removing it, but there was no change. Thanks for the suggestion!
On Sat, Jul 6, 2013 at 2:55 PM, Thomas Punt <unassailable...@hotmail.com>wrote:
> Could the comma after the last element in your array be causing the
> problem?
>
> > Date: Sat, 6 Jul 2013 14:42:07 -0400
> > From: bluethu...@gmail.com
> > To: php-gene...@lists.php.net
> > Subject: [PHP] mongo usage
>
> >
> > 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
>
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
--- End Message ---
--- Begin Message ---
>It looks like you are running the thread-safe version with
>FastCGI, which I understand to be counter to the recommendations.
Thank you for the comment.
I switched to PHP5.4.17-NTS-VC9, but the application still crashes. And still
no clue as to why.
So, still looking for that magic method to get PHP to report what's happening
on a 500 Internal Server Error when it's (presumably? not sure...) not the
server's fault.
--- End Message ---