/    Sign up×
Community /Pin to ProfileBookmark

Cannot modify header information

I know this is a very common error, and usualy i do find the output that’s send before the header is, but in this case, there’s no output in the file?

The error refers to line 1:

[CODE]updateartikel.php:1[/CODE]

Where line 1 is just the <?php tag?!?!

Anyone any ideas what to look for? What might cause any output??

Any help much appreciated

thanks,

peace

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiOct 05.2009 — You haven't posted your code so its hard to be certain, but I'm willing to bet there is whitespace before the php tag. This counts as output.
Copy linkTweet thisAlerts:
@PeaceFrogauthorOct 05.2009 — No whitespace for as far as i can tell, ive put the cursor in front of the <?php tag and backspaced myself silly, not moving a bit! Also after the ?> tag there is no whitespace, and there are no spaces before and after the (Header:blabla).

Funny enough, on the local server *windows* it didnt give this error, now that it is online *linux* it does :s

the script, left out a bunch of vars, but thats merely $bla = "blabla"; and so on
[CODE]
<?php
//ob_start();
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
error_reporting (E_ALL);
// get variables
// General variables:
$stat = $_POST['stat'];
// als produkt pending is, is de status van produkt live 0, en vice versa:
if($stat=="pending"){
$prod_pending = "1";
$prod_live = "0";
}
// more vars
// Connection to the database
include("connect_database.php");
// Check if artikel needs to be deleted
if (isset($_POST['artikelverwijderen'])){header( "Location: index.php?page=artikel_verwijderen&prod_id=$prod_id&image=$image");
}else{
// If not update the database
$result = mysql_query("UPDATE blablablablabla");
if($result){
$editResult = "Produkt ".$prod_id." is aangepast.";}else {
$editResult = "Er is iets mis gegaan";
}header( "Location: index.php?page=artikel_bewerken_result&editResult=$editResult");}
?>
[/CODE]


Where i set the vars, i also set some to $bla = ""; , but i cant imagine that having any influence?

edit#2 : the ob_start(); didnt change a thing btw

peace
Copy linkTweet thisAlerts:
@criterion9Oct 05.2009 — Does connect_database.php have any whitespace?
Copy linkTweet thisAlerts:
@PeaceFrogauthorOct 05.2009 — I didnt think of that one, but no:

[CODE]
<?php
$dbHost = "blabla";
$dbUser = "blabla";
$dbPass = "blabla";
$dbDatabase = "blabla";
//connect to the database
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
?>
[/CODE]


I use the same file for other parts to connect to the db, it does connect, no problem.

edit:

I also had a look at the source of the page showing the error. I'm not sure if it "normally" does, but it shows a <br /> and then the error message in between <b> tags. Like said, i dont know if the break comes from the error message or if its the output the error is about?


peace
Copy linkTweet thisAlerts:
@NihilisteOct 05.2009 — Maybe it has something to do with the mysterious characters that some editor let in files and that appears when you pass from Windows to Linux.

Try opening your file/s with nano or vi under Linux, if there's some you'll see.

MGB
Copy linkTweet thisAlerts:
@MindzaiOct 05.2009 — Yes I would check that you are using unix line endings and make sure your editor is not inserting invisible crap. Also you are not exit() ing after the header redirect. Very unlikely to be related but just so you know.
Copy linkTweet thisAlerts:
@PeaceFrogauthorOct 05.2009 — The exit() didnt do anything unfortunately.

Googling those mysterious characters Nihilste mentioned, got me an article describing the same problem basically, which got me to be pretty sure this also must be the problem im having.

The writer found that the problem was an UTF-8 indicator, which makes the first line:
<i>
</i>&lt;U+FEFF&gt;&lt;?php


Now my problem at the moment is that i dont have linux, googling for a windows-like program as the ones mentioned didnt get me anywhere yet. Any ways to work around it, and get rid of the <U+FEEF> bit? (assuming its there)



peace
Copy linkTweet thisAlerts:
@MindzaiOct 05.2009 — Komodo Edit (which I think is also available for windows) has an option to remove the BOM (which I assume this is) when opening files.
Copy linkTweet thisAlerts:
@criterion9Oct 05.2009 — You could also open the files with notepad and save them as ANSI type.
Copy linkTweet thisAlerts:
@PeaceFrogauthorOct 05.2009 — That did the trick! ?

I've probably messed around too much in the file, the mysql query doesnt work anymore, but the error doesnt come up!

Thanks a lot to all for your thoughts and help!


Brilliant, cheers!


peace
Copy linkTweet thisAlerts:
@PeaceFrogauthorOct 05.2009 — To be complete: the mysql query works as well now.


Thanks again lads!


peace
×

Success!

Help @PeaceFrog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...