• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6708
  • Last Modified:

PHP Error: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set

I used the below code in http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23509647.html to post my form data to another script.jsp url, it is a payment checkout (should redirect to that)

<?php
$name = $_POST['name]';
$age = $_POST['age]';
$code = $_POST['code]';

$url1 = "http://your_first_script.jsp";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'name=$name&age=$age&code=$code'); // html form POST fields replace with your form data

curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$result = curl_exec($ch);
curl_close($ch);
//echo $result;

//$url2 = "url2.php";
//....
//....
?>

I got an error:

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/public_html/html/send.php on line 47

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/public_html/html/send.php on line 57

However my php ver 4.4.8 has safe mode off and open basedir is not set

Any idea?
0
jedistar
Asked:
jedistar
  • 3
  • 2
1 Solution
 
hieloCommented:
Try:
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
0
 
jedistarAuthor Commented:
Got a warning first for 2 secs, then it redirects to the page.

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/public_html/html/send.php on line 48

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/public_html/html/send.php on line 58

HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=0B1225EC74E0D9584C5E1E722E541727; Path=/ Content-Type: text/html Content-Length: 2189 Date: Tue, 24 Jun 2008 13:59:13 GMT

How do i remove the warning?
0
 
hieloCommented:
>>How do i remove the warning?
try:
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
0
 
jedistarAuthor Commented:
Its left with stalling at this page for 2 secs showing:

HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=B7B188B4AED2C1F76963DC6A061110F6; Path=/ Content-Type: text/html Content-Length: 2189 Date: Tue, 24 Jun 2008 14:06:40 GMT
0
 
hieloCommented:
Try:
curl_setopt($ch, CURLOPT_HEADER, 0);
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now