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,690 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 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