I have this page that I’m going a CURL POSTing some info to another site of mine, but I have a error and I can’t find the cause.
The error:
Parse error: syntax error, unexpected T_STRING in /home/aaran/public_html/tests/will/1.php on line 13
(that’s the line with the CURLOPT_POSTFIELDS on).
Here’s the URL to see the script: http://hm.vc/tests/will/1.php
The script:
<?php
foreach($_GET as $key => $value){
$input[$key] = urldecode(strip_tags($value));
}
$secureurl = "http://hm.vc/tests/will/2.php";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $secureurl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $input);
$hello = curl_exec($curl);
curl_close($curl);
echo "Hi " . $input['name'] . ", Thanks for blah blah blah blah";
?>
Since I don’t know what data you’re using in the
$_GETarray, I can only guess, but as mentioned already, do aprint_r($input)after creating it to see exactly what data you’re passing.It seems that using an array for
CURLOPT_POSTFIELDSrequires that all values be scalar. If one of your$_GETvariables is an array, you might be running into a problem. See the comments at http://php.net/manual/en/function.curl-setopt.php, specifically 28-Jul-2010, which states:Could that be it?