Page 1 of 1

Headers

Posted: Sat Mar 25, 2006 2:24 am
by geeshan
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


this is my coding

Code: Select all

<html>
<body>
<?
$id = $_REQUEST['did'];
try
{
	$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 
	$conn -> Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath("db1.mdb"));
	$conn -> Execute("update articles set hits=hits+1 where articleID=$id");
	header("Location: http://svrmlb/webhost4/dit3m2-0611/EC/EC Project/Articles/aa.doc");
}
catch(Exception $g)
{
	echo $g;
}
?>
</body>
</html>
it gives me this error.

Warning: Cannot modify header information - headers already sent by (output started at E:\4thYear\dit3m2-0611\ec\ec project\count.php:3) in E:\4thYear\dit3m2-0611\ec\ec project\count.php on line 10

I read about the tutorial about headers wrote by site admin. but didnt understand why this happen.

Can u please tell me what is the wrong with this.

Geeshan


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sat Mar 25, 2006 2:28 am
by s.dot
put this

<html>
<body>

after your php code
not before

Posted: Sat Mar 25, 2006 2:50 am
by geeshan
Thanks a lot scottayy.
It wotrked.

Posted: Sat Mar 25, 2006 3:31 am
by s.dot
The link feyd posted was a good link to read ;)

When you send HTML or any other output you're sending headers. Then you try to send another header by calling header() and it can't do it because it already sent them.