0

Wherever i put -

session_start();

It gives me error :

Header may not contain more than a 
single header, 
new line detected in /home/studiom/public_html/metriconline/tumblr/connect.php 
on line next to session_start();

My Code is :

<?php
if(!ini_get('date.timezone'))
{
date_default_timezone_set('Asia/Kolkata');
}
require_once('tumblroauth/tumblroauth.php');
if(!session_id()){session_start();}
$consumer_key="myconsumerkey";$consumer_secret="secretkey";
$callback_url = "http://jrtrjujut.com/folder/tumblr/callback.php";
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret);
$request_token = $tum_oauth->getRequestToken($callback_url);
$_SESSION['request_token'] = $token = $request_token['oauth_token'];
$_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
switch ($tum_oauth->http_code)
{
case 200:
$url = $tum_oauth->getAuthorizeURL($token);
header('Location: ' . $url);
break;
default:
echo 'Could not connect to Tumblr. Refresh the page or try again later.';
}
exit();
?>

Warning: Header may not contain more than a single header, new line detected in /home/studiom/public_html/metriconline/tumblr/connect.php on line 7

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/studiom/public_html/metriconline/tumblr/connect.php:7) in /home/studiom/public_html/metriconline/tumblr/connect.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at /home/studiom/public_html/metriconline/tumblr/connect.php:7) in /home/studiom/public_html/metriconline/tumblr/connect.php on line 17

1 Answers1

0

use session_start() at the top of page may be you have already started so do a check for this

<?php if(!session_id()){session_start();}

For more about this error How to fix "Headers already sent" error in PHP

Community
  • 1
  • 1
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
  • Now my code looks like this-> As you said. still errors . & errors increased kindly look above i have updated code above as you said – user3844149 Jan 12 '15 at 06:20
  • try encode your urls by urlencode() follow http://stackoverflow.com/questions/20486000/warning-header-may-not-contain-more-than-a-single-header-new-line-detected – Rakesh Sharma Jan 12 '15 at 06:27
  • Updated again... still not getting where is the exact error.. wherever i put session_start() at the next line it gives me error – user3844149 Jan 12 '15 at 06:36
  • Even output has not started anywhere as it says "Output started on line no 7" – user3844149 Jan 12 '15 at 06:37