Headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
geeshan
Forum Newbie
Posts: 10
Joined: Fri Mar 24, 2006 12:02 am

Headers

Post 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]
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

put this

<html>
<body>

after your php code
not before
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
geeshan
Forum Newbie
Posts: 10
Joined: Fri Mar 24, 2006 12:02 am

Post by geeshan »

Thanks a lot scottayy.
It wotrked.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply