dabip Posted May 21, 2006 Share Posted May 21, 2006 Hello, I have searched, and searched, I have found sites that are supposed to help, but they don't. I have two forms of SQL - PHP working. One on my computer, and another on an outer computer web server (free hosting). I develop on my computer (to save bandwidth) and then put it on the server and quickly test it. Well, I'm making a forum, and everything seems to work really well on my computer. When I put it on the server, I had a few header problems. I read about tweaking php system files, but since its not my server, I can't. Error I get:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 38Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 39Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 40Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 41You've been logged in! Click Here to go BackWarning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 58Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 58Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 59[/quote]All code on the error page, everything is going through (so I know, such as the $_POST items) it just seems to be the header. [code]$username = "user10342";$password = "(Its a secret :) )";$hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");$selected = mysql_select_db("12141",$dbh) or die("Could not select dab"); $once = 0;if (isset($_COOKIE['in'])){ ob_start(); setcookie("in", "", time()-36000); setcookie("upass", "", time()-36000); setcookie("id", "", time()-36000); ob_end_flush(); echo "You've been logged Out. <a href=index.php> Click Here to go Back</a>"; //header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header //header("Location: index.php"); // Jump to the link } else {if (isset($_POST['name']) && isset($_POST['pass'])){ $user=$_POST['name']; $pass=$_POST['pass']; $user=mysql_real_escape_string($user); $pass=mysql_real_escape_string($pass); $sql22 = "select login, password, id from users where login='$user' and password='$pass'"; $result22=mysql_query($sql22); if (mysql_num_rows($result22) > 0) { ob_start(); setcookie("in", $user, time()+36000); setcookie("upass", $pass, time()+36000); header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header header("Location: index.php"); // Jump to the link ob_end_flush(); echo("You've been logged in! <a href=index.php> Click Here to go Back</a>"); } else { echo("Whoops! Wrong user name or password!<a href='index.php'> Click Here to Make an account</a>"); }}$once =0;$result2 = mysql_query("SELECT name, password, id FROM users where name = '$user' and password = '$pass' ");while ($row = mysql_fetch_array($result2)) { if ($once == 0){ session_start(); setcookie("id", $row['id'], time()+36000); $once = 1; break;}}}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/ Share on other sites More sharing options...
jeremywesselman Posted May 21, 2006 Share Posted May 21, 2006 [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63200\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63200[/a]Many people have the same problem. Try to search the forum before posting a question that has been answered extensively.[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--] Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37618 Share on other sites More sharing options...
dabip Posted May 22, 2006 Author Share Posted May 22, 2006 Well, I checked out the link, and I read what it had to say about header sending. I don't see my problem, as I'm not sending any HTML at all. No echoing, nothing. The code you saw was all that was saved on the file. (besides the <?php tags). Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37846 Share on other sites More sharing options...
Crimpage Posted May 22, 2006 Share Posted May 22, 2006 View the source of the page when you get these errors and post the top say, 30 lines here.That should show you what has been sent already.Also have you got and include()'s that might be putting something to screen? Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37847 Share on other sites More sharing options...
dabip Posted May 22, 2006 Author Share Posted May 22, 2006 No, I don't have any includes. Here is the resulting HTML code from the page that has errors.[code]<br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>38</b><br /><br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>39</b><br /><br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>40</b><br /><br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>41</b><br />You've been logged in! <a href=index.php> Click Here to go Back</a><br /><b>Warning</b>: session_start(): Cannot send session cookie - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>58</b><br /><br /><b>Warning</b>: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>58</b><br /><br /><b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>59</b><br />[/code]Here is the URL to the file-ish. Just type in admin for the username then guest for the password (all lowercase). Then you will get the error page right when you hit login.[a href=\"http://dabgames.3000mb.com/forum/\" target=\"_blank\"]http://dabgames.3000mb.com/forum/[/a] Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37850 Share on other sites More sharing options...
.josh Posted May 22, 2006 Share Posted May 22, 2006 so uh.. what about that br tag up there? Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37853 Share on other sites More sharing options...
trq Posted May 22, 2006 Share Posted May 22, 2006 That <br /> tag is part of the error output, however, there does seem to be some whitespace. make sure there is nothing (no whitespace) before your <?php tags. Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37857 Share on other sites More sharing options...
dabip Posted May 22, 2006 Author Share Posted May 22, 2006 That space was from the forum. It's not really there on the code. And there isn't any spaces on the top <?php either. Code of the top:[code]<?php$username = "user10342";$password = " Secret ";$hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");$selected = mysql_select_db("12141",$dbh) or die("Could not select dab"); $once = 0;if (isset($_COOKIE['in'])){[/code]That is only the top of the code. Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-37859 Share on other sites More sharing options...
dabip Posted May 24, 2006 Author Share Posted May 24, 2006 So would anyone happen to know what my problem could be? Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-38426 Share on other sites More sharing options...
.josh Posted May 24, 2006 Share Posted May 24, 2006 is that file being included into another file? Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-38431 Share on other sites More sharing options...
dabip Posted May 24, 2006 Author Share Posted May 24, 2006 No. I'm going to it from a form.So, on index, I have a form that asks for the username and password, and when you hit login, I get the data through the $_POST command.It seems the problems are only the cookie and the head( commands.So, setcookie("in", "", time()-36000); setcookie("upass", "", time()-36000); setcookie("id", "", time()-36000);and setcookie("in", $user, time()+36000); setcookie("upass", $pass, time()+36000); header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header header("Location: index.php"); // Jump to the link are the problemed code.Here is the Index login code:[code]echo "You are not logged in!<br /><form method='POST' action='in.php'> <p>Name : <input type='text' rows='1' name='name' cols='20' size='52'><br> Passqord : <input type='password' name='pass' size='52'><br> <p><input type='submit' value='Log In' name='B1'></p></form>"; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-38443 Share on other sites More sharing options...
dabip Posted May 26, 2006 Author Share Posted May 26, 2006 Well, some how I got it.I (searched for the error and found/)read:[a href=\"http://www.webmasterworld.com/forum88/1100.htm\" target=\"_blank\"]http://www.webmasterworld.com/forum88/1100.htm[/a]And tried what the guy on the last post did. And it worked for me too. I think that mabye my cache or something had a bit of the old code too. So, deleting the old one, creating a new text file, might of triggered a complete file refresh or something. I'm not sure. But it works perfect now. Thanks everyone for the help! :) Quote Link to comment https://forums.phpfreaks.com/topic/10109-help-with-header-sending/#findComment-39080 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.