Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6344557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:39:44+00:00 2026-05-24T20:39:44+00:00

I am using couchDB to get a UUID so that I can send a

  • 0

I am using couchDB to get a UUID so that I can send a new document to the database.

In order to get this UUID, I use a curl statement:

function getUUID(){
    $myCurlSubmit = curl_init();

    curl_setopt($myCurlSubmit, CURLOPT_URL, 'http://localhost:5984/_uuids');    
    curl_setopt($myCurlSubmit, CURLOPT_HEADER, 0);

    $response = curl_exec($myCurlSubmit);

    curl_close($myCurlSubmit);

    return $response;
}

This returns the expected result:

{"uuids":["af09ffd3cf4b35c2d94d1ed755000fb8"]}

However, the following json_decode fails:

print_r('No match, creating new document.');
$uuid = json_decode(trim(getUUID()));
var_dump(json_last_error());

The error printed is: ‘int(0)’ (not in quotes.), and $uuid is a json string still.

Help appreciated Thank you!

EDIT:

var_dump($uuid) = int(1)

EDIT:
var_dump(getUUID()) = {“uuids”:[“af09ffd3cf4b35c2d94d1ed755000fb8”]}\n1

Is there any reason why I would have a trailing one, and /n on my json??

EDIT:

The problem was with curl, look at the answer below!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:39:47+00:00Added an answer on May 24, 2026 at 8:39 pm

    The problem lies in the use of curl in the getUUID() function.

    You must set CURLOPT_RETURNTRANSFER, otherwise curl_exec will just echo the result, while returning 1 (as you see).

    See for example this comment in the curl_exec manual: http://www.php.net/manual/de/function.curl-exec.php#13020

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At work, we recently started a project using CouchDB (a document-oriented database). I've been
How can I get a list of all design documents in CouchDB? Using a
Using CouchDB , I currently have a document which represents an idea, you can
I am evaluating using CouchDB in my new Django-project. Is there a good database
I am trying to connect to my CouchDB database on Cloudant using Node.js. This
I was looking into the possibility of using CouchDB. I heard that it was
We are writing a Rails application that is using CouchDB as its data store.
CouchDB, version 0.10.0, using native erlang views. I have a simple document of the
Using PyObjC , you can use Python to write Cocoa applications for OS X.
I am looking for a way to insert a document into a CouchDB database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.