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 8211055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:17:50+00:00 2026-06-07T10:17:50+00:00

Heres my bit o’ php, tryin to figure out why I’m not getting a

  • 0

Heres my bit o’ php, tryin to figure out why I’m not getting a $result going to the URL it produces will give me a valid JSON result based on a get or post. So I think my problem is how I am using cURL. So I need someone take on this.

        //open connection
        $ch = curl_init();
        //set the url, number of POST vars, POST data
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_POST,count($params));
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        //execute post
        $result = curl_exec($ch);           
                    if(!$result)
                    {
                        $error = curl_error($ch); echo $error; return false;
                    }
        //close connection
        curl_close($ch);

        //return json_decode($result);
                    echo $result;

EDITED CODE ABOVE From original Post

$error does not report anything. I changed the return json… to echo to see if that was doing anything and it printed out ‘Disallowed Key Characters.‘ on the screen.

EDIT 2

$url = http://domain.com/search
$params = array('q'=>'search,term')

$params is put through a foreach loop which builds the $fields_string

$fields_string = '?';
foreach($params as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
$fields_string = substr($fields_string,0,-1);

fields_string looks like ?ll=37.2790669,-121.874722&range=10 in the end (for what I am doing currently, I have anywhere from 1-12 optional parameters that can be passed which is why I am building it the way I am.

  • 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-06-07T10:17:52+00:00Added an answer on June 7, 2026 at 10:17 am

    Try adding error checking to make sure curl_exec is executing successfully and to get a meaningful error message back on the server.

    something like:

        $ch = curl_init();
        //Make string url safe with urlencode
        curl_setopt($ch,CURLOPT_URL,urlencode($url));
        curl_setopt($ch,CURLOPT_POST,count($params));
        curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        if(!$result) {
            $error = curl_error();
            //$error now contains the error thrown when curl_exec failed to execute
            //echo this to terminal or to an error box in the browser?
        }
        curl_close($ch);
    
        return json_decode($result);
    

    Post your resulting error here if you still need help.
    Also, here are the manual pages for the two functions I took advantage of:

    http://www.php.net/manual/en/function.curl-error.php

    http://www.php.net/manual/en/function.curl-exec.php

    http://php.net/manual/en/function.urlencode.php

    -Cheers

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

Sidebar

Related Questions

a bit of a PHP / MySQL newbie here... I've been building a PHP-based
This is a bit like the popular relative time (ago) except I'm not dealing
Im working on this bit of code and I keep getting a segmentation fault.
This is a bit of a WPF whodunnit! My validation temples it not appearing
Hey I came up with a small bit of php code, after looking at
Here's a bit of an abstract question. Would it be appropriate to say that
I'm rusty a bit here. I have a vector (camDirectionX, camDirectionY, camDirectionZ) that represents
OK, I confess at the outset I'm over my head a bit here. I've
Here's the relevant bit of the source code: class Dice { String name ;
Bit confused here, I have an on-demand instance but do I get charged even

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.