RTS Posted September 6, 2006 Share Posted September 6, 2006 I am trying to send a cookie from a page. I have this,[code=php:0]<html><body><?php[color=green]setcookie("user", "$user", time()+3600); ?>[/color]<title>coke's Profile</title><link rel="shortcut icon" href="logo.ico" type="image/x-icon" /><body bgcolor=<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT bgcolor FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[bgcolor]);}?>><body background=<?php$sql2 = "SELECT bgimg FROM users WHERE username = '$user'";$result2 = mysql_query($sql2) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result2)) { print($row[bgimg]);}mysql_close($con);?> width=100% hight=100%><div align="center"><a href="home.html"> <embed src="images/yaddayay_banner.jpg"></embed></a><embed src="images/home.jpg" width="728" hight="30" usemap="#barmap"></embed><map id="barmap" name="barmap"><area shape="rect"coords="0,30,59,0" alt="Home"href="home.php"><area shape="rect"coords="60,30,104,0"alt="join"href="register.php"><area shape="rect"coords="105,30,262,0"alt="music"href="music.html"><area shape="rect"coords="263,30,336,0"alt="concerts"href="concerts.html"><area shape="rect"coords="337,30,452,0"alt="search"href="profile search.html"><area shape="rect"coords="453,30,513,0"alt="games"href="games.php"><area shape="rect"coords="514,30,619,0"alt="blogs"href="blogs.php"><area shape="rect"coords="615,30,730,0"alt="radio"href="radio.html"><table width=734 cellpadding=0 cellspacing=3><tr><td bgcolor=336699style="border-top:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-bottom:6px gray<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-right:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-left:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;"><div align=center><FONT color=<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT headcolor FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[headcolor]);}?> size=+5><MARQUEE bgcolor=#336699 direction=right loop=20 width=100%><STRONG><?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT headline FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[headline]);}?></STRONG></MARQUEE></FONT></DIV></td></tr></table><?if(file_exists("counters/coke.dat")){ $exist_file = fopen("counters/coke.dat", "r"); $new_count = fgets($exist_file, 255); $new_count++; fclose($exist_file); $exist_count = fopen("counters/coke.dat", "w"); fputs($exist_count, $new_count); fclose($exist_count);}else{$new_file = fopen("counters/coke.dat", "w");fputs($new_file, "1");fclose($new_file);}?><div style=" top: 200; left: 143; position: absolute; z-index: 1; visibility: show;"><table width=332 cellpadding=0 cellspacing=3><tr><td bgcolor=336699style="border-top:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-bottom:6px gray<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-right:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-left:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;"><h3 align=center>coke's Profile</h3><img src=images/pictures/<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT pic FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[pic]);}mysql_close($con);?>></td></tr></table><div style=" top: 0; left: 406; position: absolute; z-index: 1; visibility: show;"><table width=332 cellpadding=0 cellspacing=3><tr><td bgcolor=336699style="border-top:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-bottom:6px gray<?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-right:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;border-left:6px gray <?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT tableborder FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[tableborder]);}?>;"><h3 align=center>About Me</h3><?php$user = "coke";$con = mysql_connect( "localhost", "ZackBabtkis", "") or die(mysql_error());mysql_select_db(test, $con);$sql = "SELECT about FROM users WHERE username = '$user'";$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $query); // what's wrong?while($row = mysql_fetch_array($result)) { print($row[about]);}mysql_close($con);?></td></tr></table><form action=add.php method=post><input type=submit value=Add!/></form></body></html> [/code]But I get this error when I load the page with that on it [code]Warning: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/users/coke.php:2) in /Library/WebServer/Documents/users/coke.php on line 3[/code] Quote Link to comment Share on other sites More sharing options...
pikemsu28 Posted September 6, 2006 Share Posted September 6, 2006 set your cookie before the html code.<?php setcookie.........?><html>if the html is sent before the cookie you will receive the warning. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.