You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Daniel Brüggemann <db...@barfooz.de> on 2009/10/23 05:18:52 UTC

CouchDB PHP Problem.

Hi,

i try to replicate the code from this site:
http://wiki.apache.org/couchdb/Getting_started_with_PHP
in my own words.
But there is not the result, i hope to get.

http://nopaste.info/2b89f3eab7.html
This is the Code. What am i doing wrong?

Re: CouchDB PHP Problem.

Posted by Nicholas Orr <ni...@zxgen.net>.
>From what I can tell you appear to be doing things in a "pure" way - open a
socket, do all the http protocol stuff manually.
I'd suggest using the curl (may need to re-compile php with curl support)
and do what you want in an assisted way...

Nick

On Fri, Oct 23, 2009 at 4:49 PM, Daniel Brüggemann <db...@barfooz.de> wrote:

> These are the last line at my error log:
> http://nopaste.info/9c250f5f77.html
>
> http://localhost:5984/ and http://localhost:5984/_all_dbs
> Are run and do what they should do.
>
> On Thu, 22 Oct 2009 22:31:44 -0700, Nadav Samet <th...@gmail.com>
> wrote:
> > On Thu, Oct 22, 2009 at 10:17 PM, Daniel Brüggemann <db...@barfooz.de>
> wrote:
> >
> >> Where can i find the error logs?
> >>
> > Depends on your installation, but on a *nix it is likely to be under one
> of
> > the var/log directories (i.e. /usr/local/var/log, /var/log, etc)
> >
> > You can verify that couchdb is running by following
> http://localhost:5984/
> > and
> > http://localhost:5984/_all_dbs assuming that the browser is running on
> the
> > same machine that runs couchdb.
> >
> >
> >
> >
> >>
> >> I start the script, then, it take some time, after that,
> >> this is the result:
> >>
> >> GET /_all_dbs HTTP/1.1\r\nHOST: locahost\r\nContent-Type: text/plain;
> >> charset=utf-8\r\n\r\n
> >>
> >> Array
> >> (
> >>    [0] =>
> >> )
> >>
> >> I located the problem between the lines 51 and 54.
> >> When i comment the passage, the script is running.
> >>
> >> On Thu, 22 Oct 2009 20:39:07 -0700, Jim Kass <ji...@nhrevolution.com>
> >> wrote:
> >> > I recommend using context streams or curl.
> >> >
> >> > Btw, what result are you getting?
> >> >
> >> > Jim
> >> >
> >> > Sent from my iPhone
> >> >
> >> > On Oct 22, 2009, at 8:28 PM, Paul Davis <pa...@gmail.com>
> >> > wrote:
> >> >
> >> >> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de>
> >> >> wrote:
> >> >>> Hi,
> >> >>>
> >> >>> i try to replicate the code from this site:
> >> >>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
> >> >>> in my own words.
> >> >>> But there is not the result, i hope to get.
> >> >>>
> >> >>> http://nopaste.info/2b89f3eab7.html
> >> >>> This is the Code. What am i doing wrong?
> >> >>>
> >> >>
> >> >> Daniel,
> >> >>
> >> >> Can you paste any errors from the CouchDB logs that you're getting?
> Or
> >> >> the HTTP response? I'm not overly familiar with PHP so an error
> >> >> message might help pinpoint the issue.
> >> >>
> >> >> Paul Davis
> >>
>

Re: CouchDB PHP Problem.

Posted by Jim Kass <ji...@nhrevolution.com>.
Daniel,

Looking through your code there are a number of bugs.

1) In order for /r/n to be interpolated properly in your header you  
must use double-quoted strings.  Currently you are sending a single  
line with the chars /r/n.

2) Line 15 needs to match the host in config with a colon before port  
number.   I.e. "Host: localhost:5984"

3) line 18 should use "!==" not "!=".

4) you are not closing your socket - which although it wont break, is  
a bad habit.

This will work with these changes however pure socket programming is a  
bit more complex than your considering. For one thing in your code the  
socket will not close right away which is why you see such a long delay.

Even once the data is retrieved this is still an issue. This is  
probably due to blocking on the open socket and waiting for the socket  
to timeout.

Then again couch may not be sending a proper EOF, so who knows.

Strongly recommend you use cURL, context streams or just refer to an  
existing REST library for Couch in PHP.

HTH,
Jim

On Oct 22, 2009, at 10:49 PM, Daniel Brüggemann <db...@barfooz.de> wrote:

> These are the last line at my error log:
> http://nopaste.info/9c250f5f77.html
>
> http://localhost:5984/ and http://localhost:5984/_all_dbs
> Are run and do what they should do.
>
> On Thu, 22 Oct 2009 22:31:44 -0700, Nadav Samet <th...@gmail.com>
> wrote:
>> On Thu, Oct 22, 2009 at 10:17 PM, Daniel Brüggemann <db...@barfooz.de>
> wrote:
>>
>>> Where can i find the error logs?
>>>
>> Depends on your installation, but on a *nix it is likely to be  
>> under one
> of
>> the var/log directories (i.e. /usr/local/var/log, /var/log, etc)
>>
>> You can verify that couchdb is running by following
> http://localhost:5984/
>> and
>> http://localhost:5984/_all_dbs assuming that the browser is running  
>> on
> the
>> same machine that runs couchdb.
>>
>>
>>
>>
>>>
>>> I start the script, then, it take some time, after that,
>>> this is the result:
>>>
>>> GET /_all_dbs HTTP/1.1\r\nHOST: locahost\r\nContent-Type: text/ 
>>> plain;
>>> charset=utf-8\r\n\r\n
>>>
>>> Array
>>> (
>>>   [0] =>
>>> )
>>>
>>> I located the problem between the lines 51 and 54.
>>> When i comment the passage, the script is running.
>>>
>>> On Thu, 22 Oct 2009 20:39:07 -0700, Jim Kass <ji...@nhrevolution.com>
>>> wrote:
>>>> I recommend using context streams or curl.
>>>>
>>>> Btw, what result are you getting?
>>>>
>>>> Jim
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Oct 22, 2009, at 8:28 PM, Paul Davis <paul.joseph.davis@gmail.com 
>>>> >
>>>> wrote:
>>>>
>>>>> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db@barf 
>>>>> ooz.de>
>>>>> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> i try to replicate the code from this site:
>>>>>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
>>>>>> in my own words.
>>>>>> But there is not the result, i hope to get.
>>>>>>
>>>>>> http://nopaste.info/2b89f3eab7.html
>>>>>> This is the Code. What am i doing wrong?
>>>>>>
>>>>>
>>>>> Daniel,
>>>>>
>>>>> Can you paste any errors from the CouchDB logs that you're  
>>>>> getting?
> Or
>>>>> the HTTP response? I'm not overly familiar with PHP so an error
>>>>> message might help pinpoint the issue.
>>>>>
>>>>> Paul Davis
>>>

Re: CouchDB PHP Problem.

Posted by Daniel Brüggemann <db...@barfooz.de>.
These are the last line at my error log:
http://nopaste.info/9c250f5f77.html

http://localhost:5984/ and http://localhost:5984/_all_dbs
Are run and do what they should do.

On Thu, 22 Oct 2009 22:31:44 -0700, Nadav Samet <th...@gmail.com>
wrote:
> On Thu, Oct 22, 2009 at 10:17 PM, Daniel Brüggemann <db...@barfooz.de>
wrote:
> 
>> Where can i find the error logs?
>>
> Depends on your installation, but on a *nix it is likely to be under one
of
> the var/log directories (i.e. /usr/local/var/log, /var/log, etc)
> 
> You can verify that couchdb is running by following
http://localhost:5984/
> and
> http://localhost:5984/_all_dbs assuming that the browser is running on
the
> same machine that runs couchdb.
> 
> 
> 
> 
>>
>> I start the script, then, it take some time, after that,
>> this is the result:
>>
>> GET /_all_dbs HTTP/1.1\r\nHOST: locahost\r\nContent-Type: text/plain;
>> charset=utf-8\r\n\r\n
>>
>> Array
>> (
>>    [0] =>
>> )
>>
>> I located the problem between the lines 51 and 54.
>> When i comment the passage, the script is running.
>>
>> On Thu, 22 Oct 2009 20:39:07 -0700, Jim Kass <ji...@nhrevolution.com>
>> wrote:
>> > I recommend using context streams or curl.
>> >
>> > Btw, what result are you getting?
>> >
>> > Jim
>> >
>> > Sent from my iPhone
>> >
>> > On Oct 22, 2009, at 8:28 PM, Paul Davis <pa...@gmail.com>
>> > wrote:
>> >
>> >> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de>
>> >> wrote:
>> >>> Hi,
>> >>>
>> >>> i try to replicate the code from this site:
>> >>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
>> >>> in my own words.
>> >>> But there is not the result, i hope to get.
>> >>>
>> >>> http://nopaste.info/2b89f3eab7.html
>> >>> This is the Code. What am i doing wrong?
>> >>>
>> >>
>> >> Daniel,
>> >>
>> >> Can you paste any errors from the CouchDB logs that you're getting?
Or
>> >> the HTTP response? I'm not overly familiar with PHP so an error
>> >> message might help pinpoint the issue.
>> >>
>> >> Paul Davis
>>

Re: CouchDB PHP Problem.

Posted by Nadav Samet <th...@gmail.com>.
On Thu, Oct 22, 2009 at 10:17 PM, Daniel Brüggemann <db...@barfooz.de> wrote:

> Where can i find the error logs?
>
Depends on your installation, but on a *nix it is likely to be under one of
the var/log directories (i.e. /usr/local/var/log, /var/log, etc)

You can verify that couchdb is running by following http://localhost:5984/ and
http://localhost:5984/_all_dbs assuming that the browser is running on the
same machine that runs couchdb.




>
> I start the script, then, it take some time, after that,
> this is the result:
>
> GET /_all_dbs HTTP/1.1\r\nHOST: locahost\r\nContent-Type: text/plain;
> charset=utf-8\r\n\r\n
>
> Array
> (
>    [0] =>
> )
>
> I located the problem between the lines 51 and 54.
> When i comment the passage, the script is running.
>
> On Thu, 22 Oct 2009 20:39:07 -0700, Jim Kass <ji...@nhrevolution.com> wrote:
> > I recommend using context streams or curl.
> >
> > Btw, what result are you getting?
> >
> > Jim
> >
> > Sent from my iPhone
> >
> > On Oct 22, 2009, at 8:28 PM, Paul Davis <pa...@gmail.com>
> > wrote:
> >
> >> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de>
> >> wrote:
> >>> Hi,
> >>>
> >>> i try to replicate the code from this site:
> >>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
> >>> in my own words.
> >>> But there is not the result, i hope to get.
> >>>
> >>> http://nopaste.info/2b89f3eab7.html
> >>> This is the Code. What am i doing wrong?
> >>>
> >>
> >> Daniel,
> >>
> >> Can you paste any errors from the CouchDB logs that you're getting? Or
> >> the HTTP response? I'm not overly familiar with PHP so an error
> >> message might help pinpoint the issue.
> >>
> >> Paul Davis
>



-- 
Sincerely yours,
Nadav

Re: CouchDB PHP Problem.

Posted by Daniel Brüggemann <db...@barfooz.de>.
Where can i find the error logs?

I start the script, then, it take some time, after that,
this is the result:

GET /_all_dbs HTTP/1.1\r\nHOST: locahost\r\nContent-Type: text/plain;
charset=utf-8\r\n\r\n

Array
(
    [0] => 
)

I located the problem between the lines 51 and 54.
When i comment the passage, the script is running.

On Thu, 22 Oct 2009 20:39:07 -0700, Jim Kass <ji...@nhrevolution.com> wrote:
> I recommend using context streams or curl.
> 
> Btw, what result are you getting?
> 
> Jim
> 
> Sent from my iPhone
> 
> On Oct 22, 2009, at 8:28 PM, Paul Davis <pa...@gmail.com>  
> wrote:
> 
>> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de>  
>> wrote:
>>> Hi,
>>>
>>> i try to replicate the code from this site:
>>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
>>> in my own words.
>>> But there is not the result, i hope to get.
>>>
>>> http://nopaste.info/2b89f3eab7.html
>>> This is the Code. What am i doing wrong?
>>>
>>
>> Daniel,
>>
>> Can you paste any errors from the CouchDB logs that you're getting? Or
>> the HTTP response? I'm not overly familiar with PHP so an error
>> message might help pinpoint the issue.
>>
>> Paul Davis

Re: CouchDB PHP Problem.

Posted by Jim Kass <ji...@nhrevolution.com>.
I recommend using context streams or curl.

Btw, what result are you getting?

Jim

Sent from my iPhone

On Oct 22, 2009, at 8:28 PM, Paul Davis <pa...@gmail.com>  
wrote:

> On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de>  
> wrote:
>> Hi,
>>
>> i try to replicate the code from this site:
>> http://wiki.apache.org/couchdb/Getting_started_with_PHP
>> in my own words.
>> But there is not the result, i hope to get.
>>
>> http://nopaste.info/2b89f3eab7.html
>> This is the Code. What am i doing wrong?
>>
>
> Daniel,
>
> Can you paste any errors from the CouchDB logs that you're getting? Or
> the HTTP response? I'm not overly familiar with PHP so an error
> message might help pinpoint the issue.
>
> Paul Davis

Re: CouchDB PHP Problem.

Posted by Paul Davis <pa...@gmail.com>.
On Thu, Oct 22, 2009 at 11:18 PM, Daniel Brüggemann <db...@barfooz.de> wrote:
> Hi,
>
> i try to replicate the code from this site:
> http://wiki.apache.org/couchdb/Getting_started_with_PHP
> in my own words.
> But there is not the result, i hope to get.
>
> http://nopaste.info/2b89f3eab7.html
> This is the Code. What am i doing wrong?
>

Daniel,

Can you paste any errors from the CouchDB logs that you're getting? Or
the HTTP response? I'm not overly familiar with PHP so an error
message might help pinpoint the issue.

Paul Davis