Solved

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

Posted on 2008-06-24
5
6,646 Views
Last Modified: 2009-06-23
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
Comment
Question by:jedistar
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 21855372
Try:
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
0
 

Author Comment

by:jedistar
ID: 21855593
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
 
LVL 82

Expert Comment

by:hielo
ID: 21855612
>>How do i remove the warning?
try:
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
0
 

Author Comment

by:jedistar
ID: 21855650
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
 
LVL 82

Accepted Solution

by:
hielo earned 350 total points
ID: 21855699
Try:
curl_setopt($ch, CURLOPT_HEADER, 0);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now