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,615 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

20 Experts available now in Live!

Get 1:1 Help Now