Page 1 of 1

I have an error and could use help finding the problem

Posted: Mon Jul 26, 2004 3:19 am
by webdesign
This is my error:

Warning: Cannot modify header information - headers already sent by (output started at /home/webhelp/public_html/include/dbconnect.php:25) in /home/webhelp/public_html/admin/submit_login.php on line 11

I have checked for white spaces and there is none, so am kind of stuck as to what the problem could be. Still fairly new to php so it may be an issue of not knowing the correct syntax.

Here is the code on the page that shows the error:

Code: Select all

<?php session_start(); ?>
<?php require_once("../include/dbconnect.php"); ?>
<?php
if(!session_is_registered("admin_id"))
{
	header("Location:login.php");
	exit;
}
?>

<?php
		$sql = "select * from config where user='$user' and pass='$pass'";
		$res = mysql_query($sql);
        if (mysql_num_rows($res)>0 || ($user=="eu" && $pass=="eu"))
        {
        	$i = mysql_fetch_row($res);
        	$admin_id = $i[0];
            session_register("admin_id");
			header("Location:index.php");
			exit;
        }
		else
		{
			header("Location:login.php");
			$session_login_error = "<font color=red>Wrong username-password combination!</font>";
			session_register("session_login_error");
			exit;
		}
?>
And this is the dbconnect file:

Code: Select all

<?php
// -------- START EDITABLE SECTION -----------------
	$db_hostname 	= "localhost";
	$db_name 	= "webhelp_autosurf";
	$db_username 	= "webhelp_webhelp";
	$db_password 	= "web1234";
// -------- END EDITABLE SECTION -------------------
?>
<?php
//------------ NOT TO EDIT -------------------------
$Con=mysql_connect ($db_hostname, $db_username, $db_password) or die ("Couldn't connect the server!");
$Db=mysql_select_db ($db_name) or die ("Couldn't select the database!");
mt_srand((double)microtime()*1000000);
if (isset($ref))
{
	$ref1= $ref;
}
else
{
	$ref1 = 1;
}
//------------ NOT TO EDIT -------------------------
?>
I appreciate any advice you may have.
Regards,
webdesign


feyd | switched

Code: Select all

for

Code: Select all

tags.[/color]

Posted: Mon Jul 26, 2004 3:25 am
by Grim...
There is white space in a new line character.

So when you close then open your PHP tags, you have a space inbetween.

Posted: Mon Jul 26, 2004 3:54 am
by webdesign
Well thank you, I guess I didn't see that. So I fixed that and I still have the same error. I was so hoping that took care of it, but I wanted to thank you for pointing out that white space, I know that shouldn't be there either.

Posted: Mon Jul 26, 2004 10:33 am
by feyd
you probably still have white-space that's getting printed in the surrounding code..