Page 1 of 1

Curl POST puts character "0" on screen

Posted: Thu Nov 14, 2002 7:57 pm
by corin
I'm using curl to post variables to a script. It works fine, except on the output page I get a character "0" displayed for no apparent reason. If I do a view source, at the end of my script is :

<form blah blah.....
...form>
0




</body>
</html>

If I take the form out of the new page, I don't get this problem. Can anybody help me please. The curl code I'm using is :

<?
$URL="www.mydomain/newpage.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=$name & age=$age");curl_exec ($ch);
curl_close ($ch);
?>

Posted: Thu Nov 14, 2002 8:51 pm
by hob_goblin
curl_exec creats output

Code: Select all

<? 
$URL="www.mydomain/newpage.php"; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,"http://$URL"); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "name=$name & age=$age");
$curl = curl_exec ($ch); 
curl_close ($ch); 
?>
should work..

Posted: Fri Nov 15, 2002 1:52 am
by corin
Thanks, I've tried your suggestion and unfortunately I get the same result of a bogus 0 appearing. I have managed to pass my variables thro' a form now, by cheating and displaying the users input data for them to check on screen and then either 'go back' or 'continue' (with hidden variables). I would like to get the curl working tho' as it has potential for other stuff - think it's a question of dabbling with my script some more. Cheers