Current location: Hot Scripts Forums » Programming Languages » PHP » php error


php error

Reply
  #1 (permalink)  
Old 01-16-10, 03:43 PM
webGirl224 webGirl224 is offline
New Member
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
php error

Im having a problem with my last account, sorry....

When trying to redirect my php page to always include "www" i use:
<?
header('Location: http://www_my_page');
exit;
?>
i get this error message:

Warning: Cannot modify header information - headers already sent by

i do not know what to do...

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-16-10, 03:45 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Be sure this is the first line of output, prior to ANY PHP header or echo statements, and before ANY HTML.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-16-10, 03:58 PM
webGirl224 webGirl224 is offline
New Member
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
unfortunately...i have tried that - and it is still not working
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-16-10, 04:14 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by webGirl224 View Post
unfortunately...i have tried that - and it is still not working
1) Post all of the code.

2) The information that wirehopper gave you is correct and is the cause of this error 99.99999999% of the time. The chances are overwhelming that you have some character that is being output before the header() command.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-16-10, 04:56 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 377
Thanks: 6
Thanked 10 Times in 10 Posts
Watch out for white space. I dont know what type of editor your using (I use pspad) but it may have an option to show hidden characters.

Note that any single character (even a hidden one) will cause this error. The character can even be before the starting <?php tag.
__________________
This post was created with 100% recycled electrons.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-16-10, 09:44 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
If this file is included in another file, the same rules about output must be observed.

Headers must be sent prior to any output.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-17-10, 12:04 AM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
As ruteckycs says, even a simple

PHP Code:


<?php
can cause that error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-17-10, 03:18 PM
ThalesWeb ThalesWeb is offline
Newbie Coder
 
Join Date: Feb 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
My suggestion is to use ob_start() and ob_end_flush() OR to redirect the user using javascript, its much simpler and works very well:
Code:
<script> document.location.href=`http://www.mypage.com`; </script>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 01-17-10, 09:08 PM
webGirl224 webGirl224 is offline
New Member
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I cleared all of my code and unfortunately - im still getting this error...

Last edited by webGirl224; 01-17-10 at 09:11 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 01-17-10, 09:22 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by webGirl224 View Post
I cleared all of my code and unfortunately - im still getting this error...
As I said before, post all of the code. Otherwise all we can do is guess.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ and MSSQL tutorials? scott2500uk C/C++ 8 05-11-09 03:33 AM
XML causes PHP parse error greenpig PHP 6 08-21-08 02:54 PM
using PHP to handle MySQL error Alith7 PHP 1 05-09-07 10:59 AM
PHP delete from MySQL Error (PHP ERROR) _matt PHP 3 01-31-07 01:06 PM
php error plz help darkcarnival PHP 2 11-19-03 09:14 PM


All times are GMT -5. The time now is 04:39 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.