Jump to content
Larry Ullman's Book Forums
Sign in to follow this  

Recommended Posts

Hi all,


I coded the web pages according to the book'php6 and mysql5'. It was ok when I put it up on my local computer. However, when I put it up on my server, there's an error occurred. I don't how I can figure it out. Thank you in advance for your help.


The error message I got is this:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ryandivi/public_html/template-registration/includes/config.inc.php:69) in /home/ryandivi/public_html/template-registration/includes/header.html on line 8


I am posting my header page, config page and index page below..




<header page>


<?php #script 16.1 - header.html

//This page begins the HTML header for the site


//start output buffering



//initialize a session;



//check for a $page_title value;


$page_title='User Registration';





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><?php echo $page_title ?></title>


<style type="text/css" media="screen">

@import "includes/layout.css";






<div id="header">User Registration</div>

<div id="Content">

<!-- end of header -->


<config page>


<?php #script 16.3 -config.inc.php

/*This script:

* - define constants and settings

* - dictates how errors are handled

* - defines useful functions



//Document who created this site, when, why, etc



//************** settings *******************//


//Flag variable for site status



//Admin contact address;



//site URL(base for all redirections);



//location of the mysql connection script



//adjust the time zone for PHP5.1 and greeter







//********error management************//


//create the error handler

function my_error_handler ($e_number,$e_message,$e_file,$e_line,$e_vars){


//build error message

$message = "<p>An error occurred in script '$e_file' on line $e_line:$e_message\n<br/>";


//add date and time

$message .= "Date/Time: ".date('n-j-Y H:i:s')."\n<br/>";


//Append $e_vars to the $message

$message .= "<pre>".print_r($e_vars,1)."</pre>\n</p>";


if(!LIVE) {//Development (print the error)


echo'<div class="error">'.$message.'</div><br/>';


}else{//don't show the error;


//send an email to the admin;

mail(EMAIL,'Site Error!',$message,'From:email@example.com');


//only print an error message if the error isn't a notice

if($e_number != E_NOTICE){


echo'<div id="Error">A system error occurred. We apologize for the inconvenience.</div><br/>';



}// end of !LIVE if


}//end of my_error_handler


//*********************error management**************************//






<index page>



<?php #script 16.5 - index.php

// this is the main page for the site


//include the configuration file;



//set the page title and include the HTML header

$page_title = 'Welcome to this Site!';



//welcome the user (by name if they are logged in);


if(isset($_SESSION['first_name'])) {







<p>Thank you for visiting our website. It's our previlige to share lots of information with you, today! Blar Blar Blar... Blar. Blar...</p>

<p>Blar Blar Blar Blar Blar Bla rBlar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar Blar</p>


<?php //include the HTML footer file;






Thanks again and look forward to hearing from you soon.

Share this post

Link to post
Share on other sites

Hi Ryan, it look like you are sending something to the browser before the session_start() function. Remember you can not have any space at the beginning of the of your page tags, HTML, PHP. Go to


and see if there is a white space at the beginning of the you HTML tag or PHP tag and if there aren't none it could be your php.ini configuration. There are two different php.ini file, development and production environment. The production environment is what you want in when you move your site to you server.

  • Upvote 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this