I have an error and could use help finding the problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webdesign
Forum Newbie
Posts: 2
Joined: Mon Jul 26, 2004 3:19 am
Location: USA

I have an error and could use help finding the problem

Post 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]
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post 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.
webdesign
Forum Newbie
Posts: 2
Joined: Mon Jul 26, 2004 3:19 am
Location: USA

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you probably still have white-space that's getting printed in the surrounding code..
Post Reply