firecat318 Posted April 28, 2008 Share Posted April 28, 2008 Whenever I load this page, I get this following error message... Warning: Cannot modify header information - headers already sent by (output started at /home/www/**********.com/profile/index.php:13) in /home/www/***********.com/profile/header.php on line 6 This is the page that gets the error message on it... <? session_start(); $session = $_SESSION['username']; include("connection.php"); ?> <html><head><TITLE>Page</TITLE> <link rel="stylesheet" type="text/css" href="../style.css" /> <meta name="description" content="Stuff" /> </head> <body bgcolor="#E5E5E5"> <? if($session) { $username = mysql_real_escape_string($_GET['user']); $query = "SELECT * FROM `users` WHERE `username` = '$session'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $sql = mysql_query("SELECT `quote` FROM `users` WHERE `username` = '$session'"); $quote = mysql_result($sql, 0); ?> <div id="header"> <table><tr><td align="left"><table> <tr><td width="220px" height="26" id="welcome"> <a href="/"><img src="../images/logo.gif"></a></td></tr> </table> </td><td align="center"> <table> <tr><td align="center"><a href="features.php" id="top_links" class="top">features</a></td><td><b>|</b></td> <td align="center"><a href="forum" id="top_links" class="top">forums</a></td><td><b>|</b></td> <? if($session) { $query = mysql_query("SELECT `username` FROM `users` WHERE `username` = '$session'"); $row = mysql_fetch_assoc($query); echo "<td align='center'><a href='profile/?user={$row['username']}' id='top_links' class='top'>profile</a></td><td><b>|</b></td>"; } else { ?> <td align="center"><a href="register.php" id="top_links" class="top">register</a></td><td><b>|</b></td> <? } ?> <td align="center"><a href="music.php" id="top_links" class="top">music</a></td><td> <tr><td align="center"><a href="featured.php" id="top_links" class="top">featured</a></td><td><b>|</b></td> <td align="center"><a href="subscribe.php" id="top_links" class="top">subscribe</a></td><td><b>|</b></td> <td align="center"><a href="feedback.php" id="top_links" class="top">feedback</a></td><td><b>|</b></td> <td align="center"><a href="contact.php" id="top_links" class="top">contact</a></td></tr> </td> </table> <td align="right"><table> <tr><td colspan="2" align="center"><font size="-1">Profile Username Search</font></td> <td colspan="2"align="center"><img src="/images/searchicon.gif" width="25px" height="20px" alt="search"></td></tr> <tr><td colspan="2" ><input type="text" name="msearch" size="20"></td> <td colspan="2" ><input type="submit" name="submit" value="Find" class="register" title="Search for a profile"></td></tr></table> </td> <? if($session) { ?> <td align="right"> <a href="logout.php" class="forgot">Logout</a> </td> <? } ?> </table> </div> <br /> <? if($session) { include("header.php"); } ?> <div id="body"> <table width="100%"><tr><td align="left"> <div id="nice" width="200px"> Favorite Quote: <? echo "$quote"; ?> </div> </td></tr></table> </div><br /> <div id="footer" align="center"> <table> <tr><td style="font-size: 12px; font-weight: bold;" id="copywrite"> Winston © 2008</td> <td><a href="privacy.php" id="footer_links">Privacy Policy</a></td><td><b>|</b></td> <td><a href="creation.php" id="footer_links">Creation Story</a></td><td><b>|</b></td> <td><a href="advertise.php" id="footer_links">Advertisers</a></td><td><b>|</b></td> <td><a href="about.php" id="footer_links">About Us</a></td><td><b>|</b></td> <td><a href="rules.php" id="footer_links">Rules</a></td><td><b>|</b></td> <td><a href="faq.php" id="footer_links">FAQ</a></td><td><b>|</b></td> <td><a href="help.php" id="footer_links">Help</a></td></tr> </table> <? } ?> </div> </body> </html> And this is the 'header.php' page where the error comes from. <? session_start(); $session = $_SESSION['username']; if(!$session) { header("Location: http://*********/index.php"); } ?> <div id="login_header"> <table><tr><td> <a href="profile" id="these_links">Profile</a> <a href="profile/edit.php" style="font-size: 10px;">{edit}</a></td> <td><b>|</b></td> <td><a href="profile/inbox.php" id="these_links">Inbox</a></td><td><b>|</b></td> </tr></table> </div> I can't seem to find out why I always get an error when I load this page. Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 28, 2008 Share Posted April 28, 2008 It you post the whole error message, someone can directly help you. Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528867 Share on other sites More sharing options...
firecat318 Posted April 28, 2008 Author Share Posted April 28, 2008 Uhh.. Warning: Cannot modify header information - headers already sent by (output started at /home/www/mysite.com/profile/index.php:13) in /home/www/mysite.com/profile/header.php on line 6 Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528882 Share on other sites More sharing options...
jonsjava Posted April 28, 2008 Share Posted April 28, 2008 you are outputting data to the screen, then trying to redirect them. if you output ANYTHING (even a space) to the screen, you can not do a header redirect. Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528893 Share on other sites More sharing options...
firecat318 Posted April 28, 2008 Author Share Posted April 28, 2008 So what part of the code do I need to change? Just move the redirect on the header.php file up to the top? Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528896 Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 ^yes, put it at the top. redirect them before outputting anything. Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528913 Share on other sites More sharing options...
firecat318 Posted April 28, 2008 Author Share Posted April 28, 2008 Does PHP parse the whole script, then do its thing, or does it do the actions in order that they are listed? Link to comment https://forums.phpfreaks.com/topic/103260-error-message-cant-figure-out/#findComment-528916 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.