Any ideas what is causing this error?

Warning: Cannot modify header information - headers already sent by (output started at /home/ukcaradv/public_html/conn1.php:33) in /home/ukcaradv/public_html/register1.php on line 33

Thanks

Steve

[php]

<? require_once("conn1.php"); require_once("includes1.php"); if(isset($_POST[s1])) { $q1 = "insert into Members set username = '$_POST[NewUsername]', password = '$_POST[p1]', FirstName = '$_POST[FirstName]', LastName = '$_POST[LastName]', County = '$_POST[County]', email = '$_POST[email]', RegDate = '$t' "; mysql_query($q1); if(mysql_error()) { $error = "The username $_POST[NewUsername] is already in use!
Select another one, please!
"; unset($_POST[NewUsername]); } else { $last = mysql_insert_id(); $_SESSION[AgentID] = $last; header("location:more.php"); ////////// Cause of error thought to be here exit(); } } //get the templates require_once("templates/HeaderTemplate1.php"); require_once("templates/RegistrationTemplate1.php"); require_once("templates/FooterTemplate.php"); ?>

[/php]

Above is the register1.php script. I have bolded the cause of error I think

MOD EDIT: Removed BOLDING on alleged error line and maked with comment ////////// Cause of error thought to be here

Below is the conn1.php script.

[php]

<?php //enter your MySQL database host name, often it is not necessary to edit this line $db_host = "localhost"; //enter your MySQL database username $db_username = "******"; //enter your MySQL database password $db_password = "******"; //enter your MySQL database name $db_name = "******"; //////////////////////////////////////////////////////////// ////// do not edit below this line /////// /////////////////////////////////////////////////////////// //connect to the database server $connection = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); //select database $db = mysql_select_db($db_name, $connection); session_start(); $t = time(); ?>

[/php]

MOD EDIT: Added PHP bb code tags
Please help.

Thanks

Steve

Ok, I hate to be so blunt… but this error message is very common. Did you even try to search for it?

I did searches on this forum and on google and got tons of hits.

Sorry, but I am very new to this and I am trying to alter an existing script. Basically downsizing it. For instance it used to have Phone Number, Address lines etc.

I have taken these out and it comes up with this error.

I have looked at the 2 files side by side. i.e an original and my modified and I only took out the repeated lines that refer to these boxes.

So I haven’t changed the file overall coding. Only taken out the extra lines.

Could you explain to me what you mean by the piece that was quoted.

Just for info, I did search but didn’t understand where the script was wrong or what to add to it. That is why I posted here to try to get some sort of plain answer.

Apologies for being annoying.

Steve

When using the web for sending / receiving HTML documents they typically are transfered using HTTP (HyperText Transfer Protocol). There are specifications on the protocol requirements (documented under various RFC’s-Request for comments) .

The very basics of this is that Each HTTP session essentially has a HEADER and a BODY. The header sends info such as Referer, Which version of HTTP, Date, time, Server type, etc… This information is NOT to be confused with the HTML (HyperText Markup Language). tags. That is actually part of the BODY of the HTTP session.

The header() function of PHP is used in the HEAD of the HTTP session. As it’s name suggests it is at the HEAD (or top, if you will) of the session. Once the HEAD(er) is sent you then send the BODY. Once the body is sent you CANNOT send HEADER information.

Once you send a piece of HTML (be it text or any HTML tag), the browser/server assume that the HEAD of the HTTP session is complete.

Your error message states that the HEAD of the HTTP is sent and FINISHED as you had sent some HTML (probably in an include somewhere) then you tried to send more HTTP header information. Thus the error.

I hope this makes sense. You might be able to understand it better by understanding the HTTProtocol better. You can get an overview here http://www.freesoft.org/CIE/Topics/102.htm

If I can translate this a little simpler - and use my own experiences - watch your includes. If there’s even a single space before the <? or after the ?> it will consider that output - HTML will basically think you are outputting a space outside of the PHP code - and since header() will fail if there’s ANY output before it, you got yourself an error. Check to make sure you remove any spaces or returns from your main file and includes.

Thanks to both of you.

I have finally cracked that part.

Thanks again for pesisting with me.

Steve

Sponsor our Newsletter | Privacy Policy | Terms of Service