Solved

PHP CURL problem

Posted on 2014-01-06
3
521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I speed up this PDO query 4 41
Testing a list of Emails for validity 4 35
Load string Array from file 23 42
Ordering displaying data in a drop down 3 15
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
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 dynamically set the form action using jQuery.

710 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