Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-25-2005, 11:43 AM headers error
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
Hi all could have sworn i was already a member here but i couldn't remember my username or password so had to sign up again, doh.

I'm currently getting this error message...

There is nothing above the header ("location") part in my code and ive checked in several editors and there is absolutly no white space any where, i just can't work out why this error won't get lost This is the full PHP code from plug.php


Any help would be greatly appreciated, and go easy...i'm a PHP n00b

Last edited by tarse; 04-03-2005 at 11:12 AM.. Reason: Don't like my code being up here.
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
 
Register now for full access!
Old 03-25-2005, 11:52 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
Is the code from plug.php being included by index.php after output has already been sent output to the browser?

Check around line 2 in index.php to see where the output began
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-25-2005, 12:07 PM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
Hi simptech Checked the index and i can't see anything obvious? Maybe i just don't fully understand what counts as an output? lol

This is the index file.

Last edited by tarse; 04-03-2005 at 11:13 AM.. Reason: as above
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Old 03-25-2005, 12:29 PM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
everything before <? include "plug.php"; ?> is considerred output. you cannot set headers once ANY output is sent to the browser.

you could use output buffering to avoid this, or rewrite the code to set headers before any HTML or TEXT output (echo, print, etc)
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-27-2005, 10:44 AM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
Well, i can't work out how to stop it....i removed everything from the index page aside from the include code and i STILL get the error
Could you/anyone perhaps tell me more about using 'output buffering' to do this?
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Old 03-27-2005, 11:02 AM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
try putting your php headers before your html headers on the index page ie
PHP Code:
<?php
include 'testpage.php'// what ever you have your header error page
?>
<head><title>What your title of the page is</title></head> 
<?
// then continue with your script and that may or may not fix your problems with the headers. 
?>
try putting all of you php headers before the html headers are sent hope that helps
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 03-27-2005, 04:00 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
The error is not in PLUG.PHP but in INDEX2.PHP, look at the bottom of your script and find out if there is a white space after the ?> or a line under it, if so, delete anything after the ">" and your problem will be gone.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."
SergioC is offline
Reply With Quote
View Public Profile
 
Old 03-27-2005, 06:47 PM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
There is no white space in any of the files used in the script, i've checked them all in 3 different editors.
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Old 03-27-2005, 09:43 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
Some times it could be because of the editor you used to write the file, try to write the index2.php using notepad and bein sure that you get rid of any white space at the end of the script and then save it as a text file but with the extension PHP.

I use NOTE TAB instead of notepad, it is more efficient.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."
SergioC is offline
Reply With Quote
View Public Profile
 
Old 03-28-2005, 10:09 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
Nobody has said the error was in plug.php. Eversince the initial response, index.php has been the focus. Not to mention, what Sergio points out in his 1st reply would make no difference in the issue at hand.
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!

Last edited by simptech; 03-29-2005 at 06:49 PM..
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-29-2005, 05:43 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
What about editing this line:
PHP Code:
<? include "plug.php"?>
to the following:
PHP Code:
<? include "plug.php";?>
You just have to delete the white space after ";" and before the "?>"

Please give it a try.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."
SergioC is offline
Reply With Quote
View Public Profile
 
Old 03-29-2005, 06:49 PM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
Whitespace makes no difference inside of PHP tags. The output error was caused by HTML output that was started before sending a header()
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-29-2005, 08:24 PM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
TRY Putting all of your PHP headers before the html headers and that will remove the problem. but you need to put them before html or you will get errors.

IE
Good
PHP Code:
<? include 'header.php';?>
<head><title>What ever it is and other header information in html</title></head>
<?
// Continue your php script
include 'plug.php';
Bad
PHP Code:
<head><title>What ever it is and other header information in html</title></head>
<?
include 'header.php';
include 
'plug.php';
?>
You will get errors with the last one. saying cannot send headers, headers already sent
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 03-30-2005, 10:32 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
That would have still caused errors with the original code. plug.php was trying to set headers (look at tarse's first post). Therefore, ANY output before that script was included was have resulted in the same problem.
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-30-2005, 10:35 AM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
^ that worked thanks, but another problem has appeared cos of it.


As you can see it now automatically jumps to the error-page.html that says 'Error: Invalid usage'

In this part of the code i tried making /pboard/plug.php and /pboard/index.php the valid URL but neither work

Last edited by tarse; 04-03-2005 at 11:13 AM..
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Old 03-30-2005, 11:30 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
Which browser are you using? Some do not send referrering page URLs
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-30-2005, 11:46 AM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
I use Internet Explorer, also tested it in Firefox and the same thing happens.
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Old 03-30-2005, 11:57 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
Correct me if I am wrong. Are you expecting http_referer to be index.php because plug.php is included by index.php?
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 03-30-2005, 12:53 PM
tarse's Avatar
Novice Talker

Posts: 12
Location: UK
Trades: 0
That is correct, however i have tried a bunch of other valid URLs like i said and none of them seem to work.
tarse is offline
Reply With Quote
View Public Profile Visit tarse's homepage!
 
Reply     « Reply to headers error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.73735 seconds with 12 queries