...

View Full Version : What is wrong in this??



TheCracker
11-17-2010, 12:18 PM
hi all, this is driving me crazy, i don't see anything wrong, its at top no header is being sent before, no space before it, its at top. also ob_start() is not working for me, any one know what is the problem?

i'm getting this error
Warning: Cannot modify header information - headers already sent by (output started at D:\Installed Programs\AppServ\www\syllabus.php:1) in D:\Installed Programs\AppServ\www\syllabus.php on line 9


<?php
if (!isset($_COOKIE['username']) || !isset($_COOKIE['password'])) {
echo "<META HTTP-EQUIV='Refresh' Content=0;URL='index.php?error=3'>";
}
else {
//Renew The Cookies
$myDomain = ereg_replace('^[^\.]*\.([^\.]*)\.(.*)$', '\1.\2', $_SERVER['HTTP_HOST']);
$setDomain = ($_SERVER['HTTP_HOST']) != "localhost" ? ".$myDomain" : false;
setcookie ("username", $_COOKIE['username'], time()+60*15, '/', "$setDomain", 0 );
setcookie ("password", $_COOKIE['password'], time()+60*15, '/', "$setDomain", 0 );
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
html code starts here

EDIT: I forgot to say, if i delete else{} and leave only if () it works perfectly without any error

sybil6
11-17-2010, 02:20 PM
EDIT: I forgot to say, if i delete else{} and leave only if () it works perfectly without any error
Obviously, you're echoing then setting cookies this is why you get the error, you need to find other way around this.

mlseim
11-17-2010, 02:29 PM
What happens if you just do this ....
I'm trying to determine if the problem is just within this part ...



<?php

//Renew The Cookies
$myDomain = ereg_replace('^[^\.]*\.([^\.]*)\.(.*)$', '\1.\2', $_SERVER['HTTP_HOST']);
$setDomain = ($_SERVER['HTTP_HOST']) != "localhost" ? ".$myDomain" : false;
setcookie ("username", $_COOKIE['username'], time()+60*15, '/', "$setDomain", 0 );
setcookie ("password", $_COOKIE['password'], time()+60*15, '/', "$setDomain", 0 );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
html code starts here

TheCracker
11-17-2010, 04:54 PM
@sybil: that is why i asked here because i don't know what is the problem

@mlseim: u r right, i get the same error in this page, but i use the same code for the log in page but get no error? what do u think is the problem??

Rowsdower!
11-17-2010, 04:59 PM
Have you checked for a byte order mark (BOM) (http://en.wikipedia.org/wiki/Byte_order_mark) on your files yet? This can screw everything up in a hurry.

Notepad++ can save files without BOM if you need it.

TheCracker
11-17-2010, 06:06 PM
exactly, i've copied the code in notepad++ and save as, everything went ok

but do u know how to remove BOM from expression web 12?? i don't want to use it

thanks a ton friend,
regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum