posting with cURL problem



Hello there,

I can't figure out why is it that when i use an array for my postfields
it doesn't work :

this works
curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" );

this doesn't
curl_setopt($curl, CURLOPT_POSTFIELDS, array('clown'=>'bozo') );


The web site i post to only responds when my parameters are in a
string, but it sends nothing back when i use an array - no headers, no
error, nothing. And cURL shows no error either. So there must be
something different in the way cURL posts from an array. It's like the
web site reads it differently than when i post a string and possibly
some error is generated on the server. I make other posts to the same
web site and all is okay except when i use an array. Any ideas what
might be going on?

Here is the full code

$curl = curl_init();

curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookiejar.txt' );
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookiejar.txt' );
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 2);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('clown'=>'bozo') );

curl_setopt($curl, CURLOPT_URL, 'http://www.somesite.com/form.htm');
$response = curl_exec($curl);

echo $response; // this echos nothing and when saved to a file the
file is 0 bytes...

.



Relevant Pages

  • Re: Assistance please
    ... I would appreciate some assistance please with a web site I help out with. ... The web site allows the user to select from various lists either a full list of all of the stories or a sub set of the stories based on various select statements, this works well and has been for some time. ... I was asked to add these and on the face of it, it appeared to be fairly simple but clearly the scripts needed to know which story to go to next, it could not just go to the next in the database. ... One pages where it works OK I have it,temporarily showing how big the array for this selection is, where in the array the current story is but once a user selects forward to get to a story within the records that have been deleted the array size and position within the array lose their values. ...
    (comp.lang.php)
  • Re: Sorting combobox elements
    ... I have a page on my web site regarding sorting arrays. ... function named QSortInPlace that will sort an array in either ... you can put the elements in the combobox into ... descending order, and then reload the array back into the combobox. ...
    (microsoft.public.excel.programming)
  • Assistance please
    ... I would appreciate some assistance please with a web site I help out with. ... The website is database driven with MYSQL as the back end. ... My idea was to build an array of which stories were required in the first ... // Load the memory number into the correct position within the array ...
    (comp.lang.php)
  • Re: Sorting combobox elements
    ... I have a page on my web site regarding sorting arrays. ... function named QSortInPlace that will sort an array in either ... you can put the elements in the combobox into ...
    (microsoft.public.excel.programming)
  • Re: "SafeArrayTypeMismatchException" - .NET MASTERS PLEASE HELP
    ... > Bryan Phillips ... > Blog: http://bphillips76.spaces.live.com ... > Web Site: http://www.composablesystems.net ... Might be I am unable to use the array to read data from a SAFEARRAY. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)