Solved

PHP CURL problem

Posted on 2014-01-06
3
514 Views
Last Modified: 2014-01-11
Hi all , I'm trying to user PHP curl to open a connection with another  server to send it a file  and  then  get the  reply to manipulate it ...

This worked fine with me :

        $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,$target_url);
      curl_setopt($ch, CURLOPT_POST,1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
      $result=curl_exec ($ch);
      curl_close ($ch);
      //echo $result;

But , this line :
      $result=curl_exec ($ch);
do execute the CURL connection and automatically  prints the reply even when I'm commenting   the final line " the echo statement  "
So the final  reply is always printed ...
I don't  want that ..

I want to get the result  in a variable  to manipulate it not to print ..


Any advice?
0
Comment
Question by:darroosh
  • 2
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
curl_exec() does not print anything.  There is something else going on.  Can you please post the entire script exactly as you have it now?  You can obscure passwords and things like that but please make sure that the logic and line numbers are 100% the same.  Thanks, ~Ray
0
 

Accepted Solution

by:
darroosh earned 0 total points
Comment Utility
Solved !

Thank you for  your  trial to help


I solved it  by adding the following  line :
      curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);

This  line  make CURl return the output rather than directly outputting it as PHP.net says  http://au1.php.net/curl_setopt ..
It worked  fine for me ..

Thanks  again
0
 

Author Closing Comment

by:darroosh
Comment Utility
I searched and  found the solution .. Posted it here as it may help  someone..
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now