i copied the curl example from FAQ434-2502 .
the only changes i made were to put in my data fields where the examples were.
changed
IP-resolvable FQDN of the server
$hostname = 'hostname.mysite.com
changed the CGI path
so my script looks like this:
and i got the following error:
Parse error: parse error, unexpected '=' in /var/ on line 88
line 88 is :
any idea why
the only changes i made were to put in my data fields where the examples were.
changed
IP-resolvable FQDN of the server
$hostname = 'hostname.mysite.com
changed the CGI path
so my script looks like this:
Code:
<?php
/*
There are two fundamental ways for PHP to send data to another
CGI via the POST-method: CURL and fopen.
Where CURL is the easier of the two, fopen is more commonly available.
Check the output of phpinfo() to see whether CURL is available on your system.
*/
/*
This method uses CURL to contact the server.
*/
// Either 'http' or 'https'. 'https' is only an option if OpenSSH
// is available on your system. Check phpinfo() to see whether
// HTTPS is available.
$HTTP_method = 'http';
// IP-resolvable FQDN of the server
$hostname = 'hostname.mysite.com
// Path on that server to the CGI
$cgi = '/var/[URL unfurl="true"]www/cgi-bin';[/URL]
// Array of data. The foreach loop below is going to construct a field/data
// string like the one you see in the URL of a GET-method CGI.
$my_data = array (
my data fields here
);
// This section constructs the field/value pairs of the form
// field1=value1&field2=value2&field3=value3
$data_string = ';
$add_ampersand = FALSE;
foreach ($my_data as $key => $value)
{
if ($add_ampersand)
{
$data_string .= '&';
}
$data_string .= $key . '=' . $value;
$add_ampersand = TRUE;
}
// Get a CURL handle
$curl_handle = curl_init ();
// Tell CURL the URL of the CGI
curl_setopt ($curl_handle, CURLOPT_URL, $HTTP_method . '://' . $hostname . $cgi);
// This section sets various options. See [URL unfurl="true"]http://www.php.net/manual/en/function.curl-setopt.php[/URL]
// for more details
curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl_handle, CURLOPT_POST, 1);
curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
// Perform the POST and get the data returned by the server.
$result = curl_exec ($curl_handle) or die ("There has been an error");
// Close the CURL handle
curl_close ($curl_handle);
// Process the return
print $result;
and i got the following error:
Parse error: parse error, unexpected '=' in /var/ on line 88
line 88 is :
Code:
$data_string .= $key . '=' . $value;
any idea why