What does this error mean?
Moderator: General Moderators
What does this error mean?
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\registercode.php:2) in C:\xampp\htdocs\registercode.php on line 13
Line 13 is:
session_start();
does it mean i have not ended the session or something?
Line 13 is:
session_start();
does it mean i have not ended the session or something?
I don't though! I have a php echo on line 4 but even when removed the same thing error appeared.
This is what i got, on line 11 is the session start. The only physical output to the browser is the echo mysql_error();.
But when removed i get the same error anyway... am i missing something?
This is what i got, on line 11 is the session start. The only physical output to the browser is the echo mysql_error();.
But when removed i get the same error anyway... am i missing something?
Code: Select all
<?php
if(!mysql_connect("localhost", "root", "private")){
echo mysql_error();
exit;
}
else{
mysql_select_db("civilian") or die (mysql_error());
if (isset($_POST['RegistrationSubmission'])){
session_start();
$Captcha = ($S_SESSION['security_code']);
$UserCaptcha = mysql_real_escape_string($_POST['security_code']);
if($Captcha == $UserCaptcha){
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
$Username = mysql_real_escape_string($_POST['Username']);
$Password = mysql_real_escape_string($_POST['Password']);
$Password2 = mysql_real_escape_string($_POST['Password2']);
$Email = mysql_real_escape_string($_POST['EmailRegistration']);
$Country = mysql_real_escape_string($_POST['CountryChoice']);
$ip = $_SERVER["REMOTE_ADDR"];
$Gender = $_POST['Gender'];
$TermsOfService = $_POST['TermsOfService'];
$jump2 = 1;
if ($Password != $Password2) {
echo "Passwords did not match";
if ($TermsOfService == "off") {
die('You must agree to the terms of service before registering! Please press back and try again!');
$jump2 = 0;
}
}
if ($jump2 ==1){
$chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'");
$getUSERNAME = mysql_fetch_assoc($chkUSERNAME);
if($_POST['Username'] == $getUSERNAME['Username']) {
die('Username already registered, please choose a different username! That has not already been taken!');
}
$chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'");
$getEmail = mysql_fetch_assoc($chkEmail);
if($_POST['EmailRegistration'] == $getEmail['Email']) {
die('Email is already in use please use a different valid email address!!');
}
if ($Password == $Password2) {
$query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender)
Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')";
mysql_query($query) or die(mysql_error());
unset($_SESSION['security_code']);
}}} else {
// Insert your code for showing an error message here
If($Captcha != $UserCaptcha){
//die('Your security code did not match the generated image, please try again!');
}}
}}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Well, if line 13 is session start, according to PHP, then you have something above it, because in this code, your session_start() call is on line 10:
- <?php
- if(!mysql_connect("localhost", "root", "private")){
- echo mysql_error();
- exit;
- }
- else{
- mysql_select_db("civilian") or die (mysql_error());
- if (isset($_POST['RegistrationSubmission'])){
- session_start();
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
This is exactly how it is as of right now. from line 1 to line 56.
After that it is the then the HTML for the registration form.
After that it is the then the HTML for the registration form.
Code: Select all
<?php
if(!mysql_connect("localhost", "root", "private")){
echo mysql_error();
exit;
}
else{
mysql_select_db("civilian") or die (mysql_error());
if (isset($_POST['RegistrationSubmission'])){
session_start();
$Captcha = ($S_SESSION['security_code']);
$UserCaptcha = mysql_real_escape_string($_POST['security_code']);
if($Captcha == $UserCaptcha){
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
$Username = mysql_real_escape_string($_POST['Username']);
$Password = mysql_real_escape_string($_POST['Password']);
$Password2 = mysql_real_escape_string($_POST['Password2']);
$Email = mysql_real_escape_string($_POST['EmailRegistration']);
$Country = mysql_real_escape_string($_POST['CountryChoice']);
$ip = $_SERVER["REMOTE_ADDR"];
$Gender = $_POST['Gender'];
$TermsOfService = $_POST['TermsOfService'];
$jump2 = 1;
if ($Password != $Password2) {
echo "Passwords did not match";
if ($TermsOfService == "off") {
die('You must agree to the terms of service before registering! Please press back and try again!');
$jump2 = 0;
}
}
if ($jump2 ==1){
$chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'");
$getUSERNAME = mysql_fetch_assoc($chkUSERNAME);
if($_POST['Username'] == $getUSERNAME['Username']) {
die('Username already registered, please choose a different username! That has not already been taken!');
}
$chkEmail = mysql_query("SELECT * FROM `userregistration` WHERE `Email` = '".$_POST['EmailRegistration']."'");
$getEmail = mysql_fetch_assoc($chkEmail);
if($_POST['EmailRegistration'] == $getEmail['Email']) {
die('Email is already in use please use a different valid email address!!');
}
if ($Password == $Password2) {
$query = "INSERT INTO `userregistration` (Username,Password,Email,Country,IP,Gender)
Values ('$Username', '$Password', '$Email', '$Country', '$ip', '$Gender')";
mysql_query($query) or die(mysql_error());
unset($_SESSION['security_code']);
}}} else {
// Insert your code for showing an error message here
If($Captcha != $UserCaptcha){
die('Your security code did not match the generated image, please try again!');
}}
}}
?>please tryand post the output.
Code: Select all
<?php
function foo() {
if ( headers_sent($file, $line) ) {
echo "\n<br />headers sent: ", $file, '@', $line, "<br />\n";
$c = file($file);
for($i=$line-2; $i<$line+3; $i++) {
echo "#$i: ", isset($c[$i]) ? trim($c[$i]):'', "<br />\n";
}
}
}
if(!mysql_connect("localhost", "root", "private")){
echo mysql_error();
exit;
}
else{
mysql_select_db("civilian") or die (mysql_error());
if (isset($_POST['RegistrationSubmission'])){
foo();
session_start();
$Captcha = ($S_SESSION['security_code']);
...- iknownothing
- Forum Contributor
- Posts: 337
- Joined: Sun Dec 17, 2006 11:53 pm
- Location: Sunshine Coast, Australia
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA