By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

Curl Post method executing more than once

P: 2

I am using the following curl code to post into a ASPX url. When I do the execute, curl is posting and getting the result more than once. I am not sure why. Can anyone help me on this.
$ch = curl_init();
$POSTFIELDS = "UserName=test&Password=testpapi&Name=geek";

$LOGINURL= "http://localhost/fun.aspx";

curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($result = curl_exec($ch))
echo "<pre>".$result."</pre>";
echo $result;

Please read the Posting Guidelines before you post in this forum!.
Especially the part about enclosing code within php or code tags.

Feb 12 '07 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 4,258
Are you definitely certain that you do not execute your script twice?
Because the posted code looks fine, apart from the erroneous @extract($_REQUEST) statement and the non-initialized $useragent variable.. That must return an error to you.

Ronald :cool:
Feb 12 '07 #2

P: 2

Yes I am sure about that. It executes again and again and returns value. I am totally confused with this. Please help
Feb 13 '07 #3

Expert 2.5K+
P: 4,258
In that case the only way to get on with this is to see the code of the scripts involved.

And do not forget to enclose code within php or code tags!!
  • the script that calls this script
  • the complete (error free) code of this script, because the code shown does not run without errors

Ronald :cool:
Feb 13 '07 #4

P: 2
I have the same problem in PHP.

Here's the code.

Expand|Select|Wrap|Line Numbers
  1. $url="";
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_URL, $url);
  4. curl_setopt ($ch, CURLOPT_POST, 1);
  5. curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
  6. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  7. $store = curl_exec ($ch);
  8. $content = curl_exec ($ch); # This returns HTML
  9. curl_close ($ch);
I get a success from the page I am posting to.
It gives me the "job ID" I was expecting... but for some reason the application I am posting to actually creates two jobs.

Mar 19 '07 #5

P: 2
Sorry that was a debug version where I PURPOSEFULLY made multiple calls.
I was thinking that perhaps setting the execute to a variable was causing oddness.
The $store version isn't in the code.
Mar 19 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.