Copy link to clipboard
Copied
Update: I'm looking for any ideas on this. I know it's hard without the full script. I'm more than happy to send it to you, but it is over 450 lines. All of the database functions work fine, as does an earlier version of this script from which there are only small changes to this version. I have searched through the the changes for several days.
I'm getting the following error message on a script that I briefly changed from one that worked fine. All the database manipulations work fine. This exists only on my computer right now. The messages are:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php:4) in C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php on line 76
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php:4) in C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php on line 76
Here is the code, beginning at line 75:
//Establish session variables
session_start();
$_SESSION['ss_id'] = $regis_ss_id;
$_SESSION['ss_name'] = $regis_ss_name;
$_SESSION['ss_nomonths'] = $regis_ss_nomonths;
$_SESSION['ss_cost'] = $regis_ss_cost;
$_SESSION['ss_homelink'] = $regis_ss_link;
$_SESSION['email_address'] = $regis_email_address;
$_SESSION['first_name'] = $regis_first_name;
$_SESSION['last_name'] = $regis_last_name;
MartyMatthews wrote:
I'm getting the following error message on a script that I briefly changed from one that worked fine. All the database manipulations work fine. This exists only on my computer right now. The messages are:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php:4) in C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php on line 76
The line 76 in the
...Copy link to clipboard
Copied
That error means either you have <head> tags in your html or you have sent a PHP header before that line. Do you have any "header" commands before this? What kind of code is before this line?
Copy link to clipboard
Copied
Thanks for the reply!
What follows is first 135 lines of code. As I mentioned, this code in another script, works fine. I copied that code and pasted it into a new folder. I have made sure the links are still good and the database manipulations are all good using a new table. I believe that the problem is in the combination of copying the code and the changes I made. I have done a compare of the original and the changed scripts and studied it for hours to see if I can find an error. I've also put the code in Aptana to see if it picks anything up. Nothing.
<?php require_once('../Connections/classlist.php'); ?>
<?php require_once('../Connections/ssrecords.php'); ?>
<?php
// [07] This script finalizes the registration and produces letters to Lorian and the registrant.
//The above connections provide links to the LorianSchool database for classlist and ssrecords.
//This function, generated by Dreamweaver, determines the type of information being retrieved from the database.
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
//Pick up the "record ID" (SS ID)
$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
//Get SS info from ssrecords table
mysql_select_db($database_classlist, $classlist);
$query_DetailRS1 = sprintf("SELECT * FROM ssrecords WHERE ssrecords.ss_id = %s", GetSQLValueString($colname_DetailRS1, "text"));
$DetailRS1 = mysql_query($query_DetailRS1, $classlist) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
$regis_ss_id = $row_DetailRS1['ss_id'];
$regis_ss_name = $row_DetailRS1['ss_name'];
$regis_ss_nomonths = $row_DetailRS1['ss_nomonths'];
$regis_ss_cost = $row_DetailRS1['ss_cost'];
$regis_ss_link = $row_DetailRS1['ss_homelink'];
// Pick up the email address
$colname_classentry = "-1";
if (isset($_GET['email_address'])) {
$colname_classentry = $_GET['email_address'];
}
//Get the registrant information from the nameregistration table
mysql_select_db($database_classlist, $classlist);
$query_classentry = sprintf("SELECT * FROM nameregistration WHERE nameregistration.email_address = %s", GetSQLValueString($colname_classentry, "text"));
$classentry = mysql_query($query_classentry, $classlist) or die(mysql_error());
$row_classentry = mysql_fetch_assoc($classentry);
$totalRows_classentry = mysql_num_rows($classentry);
$regis_email_address = $row_classentry['email_address'];
$regis_first_name = $row_classentry['first_name'];
$regis_last_name = $row_classentry['last_name'];
//Establish session variables
session_start();
$_SESSION['ss_id'] = $regis_ss_id;
$_SESSION['ss_name'] = $regis_ss_name;
$_SESSION['ss_nomonths'] = $regis_ss_nomonths;
$_SESSION['ss_cost'] = $regis_ss_cost;
$_SESSION['ss_homelink'] = $regis_ss_link;
$_SESSION['email_address'] = $regis_email_address;
$_SESSION['first_name'] = $regis_first_name;
$_SESSION['last_name'] = $regis_last_name;
//Prepare to write the class registration record in SSregis table
mysql_select_db($database_ssrecords, $ssrecords);
$query_registration = "SELECT * FROM ssregis";
$registration = mysql_query($query_registration, $ssrecords) or die(mysql_error());
$row_registration = mysql_fetch_assoc($registration);
$totalRows_registration = mysql_num_rows($registration);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
//On clicking Submit, insert a new record in the ssregis table
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$regis_paid_code = $_POST["submit"];
$insertSQL = sprintf("INSERT INTO ssregis (email_address, ss_id, ss_cost, reg_date, paid_code) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($regis_email_address, "text"),
GetSQLValueString($regis_ss_id, "text"),
GetSQLValueString($regis_ss_cost, "double"),
GetSQLValueString($regis_reg_date, "date"),
GetSQLValueString($regis_paid_code, "text"));
mysql_select_db($database_ssrecords, $ssrecords);
$Result1 = mysql_query($insertSQL, $ssrecords) or die(mysql_error());
$regis_regid = mysql_insert_id();
//Get ID of registration record just written in ssregis
mysql_select_db($database_ssrecords, $ssrecords);
$query_registration = "SELECT * FROM ssregis WHERE reg_id = '$regis_regid'";
$registration = mysql_query($query_registration, $classlist) or die(mysql_error());
$new_row = mysql_fetch_assoc($registration);
//If using PayPal go to Paypalregis.php
if ($regis_paid_code == "PayPal") {
$insertGoTo = "\ssregister\ss08-ppregis.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
$insertGoTo .= "®_id=".$new_row['reg_id'];
} }
else {
//If not using PayPal go to Lorian Home page.
$insertGoTo = "lorianorg01/index.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
$insertGoTo .= "®_id=".$new_row['reg_id'];
} }
header(sprintf("Location: %s", $insertGoTo));
Copy link to clipboard
Copied
Make sure you do not have any whitespace before or after your php tags. Do you have a blank before the first line of code?
Copy link to clipboard
Copied
Very similar issue discussed earlier. This could help? http://forums.adobe.com/message/2220649#2220649
Copy link to clipboard
Copied
MartyMatthews wrote:
I'm getting the following error message on a script that I briefly changed from one that worked fine. All the database manipulations work fine. This exists only on my computer right now. The messages are:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php:4) in C:\xampp\htdocs\lorianorg01\ssregister\ss07-finalregis.php on line 76
The line 76 in the error message is a red herring. It tells you where the session cookie should be sent, not where the error lies. That information is in the earlier part of the error message in parentheses.
The output started on line 4 of ss07-finalregis.php. That's where you need to look for the problem.
Copy link to clipboard
Copied
THANKS a lot!! TO David, SnakEyez02, Bregent, and Sudarshan. I really appreciate your willingness to help me and the answers you gave me. You all had the right idea. I had a blank line between two blocks of PHP code. I should know better, but missed it. Sudarshan's reference to the earlier thread with its reference to an article David Powers wrote and David's telling me to look on line 4 were the big clues.
Thanks again to everybody--you are all great!!!
Copy link to clipboard
Copied
You're welcome