Solved

PHP CURL problem

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

770 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