Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 22nd, 2002, 04:24 PM
hellalax hellalax is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 1 hellalax User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Warning: Cannot add header information - headers already sent by

Hey thanks for a great tutorial!
I'm having problems with the headers though.
The error/warning...

Warning: Cannot add header information - headers already sent by (output started at c:\phpdev\www\newshopper.php:8) in c:\phpdev\www\newshopper.php on line 21


keeps on resulting when I try using the

header('Location: login.php');
and
session_start();

The functions work when they are by themselves, but when I place them in my code, I get the warning. The data is still getting to mySQL (no problems there). Here is the code I'm using. ANY help would be greatly appreciated.

<?php
$db = mysql_connect('localhost', '') or die("Couldn't connect to the database.");
mysql_select_db('') or die("Couldn't select the database");

if (isset ($submitButton)){
$_POST['userName'] = addslashes($_POST['userName']);
$_POST['password'] = md5($_POST['password']);
$sql = "INSERT into user (userName, password, name) values ('$_POST[userName]', '$_POST[password]', '$name')";
if (mysql_query($sql)){
// Start the login session
session_start();

// We've already added slashes and MD5'd the password
$_SESSION['user'] = $_POST['userName'];
$_SESSION['pass'] = $_POST['password'];

header("Location: shoppingCart.php");
die();
}
else {
echo("error ". mysql_error());
}
}
?>

Reply With Quote
  #2  
Old November 22nd, 2002, 05:21 PM
eloso eloso is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 6 eloso User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
To be able to use in the same script session_start() and header(),
you need to add a line :

session_cache_limiter('public');

Then you can do

session_start();

and header("location : whatever.php");


You can get some more information on the PHP site at:
http://www.php.net/manual/en/function.header.php

ciao!

Reply With Quote
  #3  
Old July 16th, 2008, 02:02 AM
shahzad.arain shahzad.arain is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 shahzad.arain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 55 sec
Reputation Power: 0
Cannot add header information

warning: Cannot add header information - headers already sent in d:\web\hasp.php on line 12."
and i can't see any content.

Soultion :-

activate the flag output_buffering in the php.ini.
Step 1:-Search PHP.ini
Step 2: Find output_buffering variable
Step 3: Replace off with 4096

For instance:

output_buffering = 4096

Thanks n Regards,
Shahzad Arain
92-334-5307738

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Warning: Cannot add header information - headers already sent by


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap