Solved

PHP CURL problem

Posted on 2014-01-06
3
517 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 109

Expert Comment

by:Ray Paseur
ID: 39760346
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
ID: 39760433
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
ID: 39773126
I searched and  found the solution .. Posted it here as it may help  someone..
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

830 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