•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 370,604 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,062 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1271 | Replies: 7
![]() |
•
•
Join Date: Jun 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 1
Warning: session_start(): Cannot send session cookie - headers already sent by
i want to use session in my prog and this error comes every times due 2 which i cann't use session which is vry important for me.
but whn i run the same prog in my computer i.e. localhost it run correctly but when i load that file in the server than this error comes.
so pls help me to avoid this session error
my boss fire on me
pls pls help me
here is the my prog ----------------
[php]<? ob_start();
session_start();?>
<?php
include"db_config.php";
$connect = mysql_connect("$db_host", "$db_user", "$db_password");
mysql_select_db("$db_name", $connect) or die(mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://acmserver.cs.ucr.edu/~nkumar/vision.htm -->
<HTML>
<HEAD><TITLE>Bankon Us</TITLE>
<body topmargin="0" leftmargin="0">
<tr>
<TD align=center>
<table cellpadding="0" cellspacing="0" border=0 width="100%">
<tr><td height="25"> </td></tr>
<tr>
<td width="50%" align="right">
<?php
$_SESSION['admfname']= $_POST['fname'];
$_SESSION['admlname']= $_POST['lname'];
$_SESSION['admpassword']=$_POST['password'];
if (($_SESSION['admfname'] == "peter") and ($_SESSION['admlname'] == "gewant") and ($_SESSION['admpassword'] == "approvalagent"))
{
echo "<meta http-equiv='Refresh' content='0; url=admin_page.php'>";
exit;
}
$f_name= $_POST['fname'];
$l_name= $_POST['lname'];
$pass= $_POST['password'];
if($_POST['submit'] != "Login")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgColor="#ff9900">
<form method="post" action="<?php $_SERVER['PHP_SELF']?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your<br> Account</td>
</tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/online.jpg"></td>
</tr>
</table>
<br><br>
<?php }
elseif($f_name== "" or $l_name== "" or $pass== "")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgcolor="#00CC99">
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your Account</td>
</tr>
<tr><td> </td></tr>
<tr><td colspan="3" align="center" class="heading">Please fill all the fields</td></tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/login1.jpg" width="300" height="200"></td>
</tr>
</table>
<?php
}
else {
$query = "SELECT * from helpagent WHERE first='$f_name' and last='$l_name' and password='$pass' ";
$result = mysql_query($query);
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$id = mysql_result($result, $i, "agentid");
$fname = mysql_result($result, $i, "first");
$lname = mysql_result($result, $i, "last");
$pas = mysql_result($result, $i, "password");
if (("$f_name" == "$fname") and ("$l_name" == "$lname") and ("$pass" == "$pas"))
{
$_SESSION['sfname'] = $f_name;
$_SESSION['slname'] = $l_name;
$_SESSION['sid'] = $id;
echo "<meta http-equiv='Refresh' content='0; url=user_page.php'>";
exit;
}//if loop
}//for loop
echo "<meta http-equiv='Refresh' content='0; url=new_user.php'>";
exit;
}
?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr>
<td>
<table border="0" width="100%">
<tr><td align="center" class="copy">Copyright © 2006 www.bankon.us All Rights Reserved</td></tr>
</table>
</td>
</tr>
</td>
</tr>
</table>
</BODY>
</HTML>[/php]
i want to use session in my prog and this error comes every times due 2 which i cann't use session which is vry important for me.
but whn i run the same prog in my computer i.e. localhost it run correctly but when i load that file in the server than this error comes.
so pls help me to avoid this session error
my boss fire on me
pls pls help me
here is the my prog ----------------
[php]<? ob_start();
session_start();?>
<?php
include"db_config.php";
$connect = mysql_connect("$db_host", "$db_user", "$db_password");
mysql_select_db("$db_name", $connect) or die(mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://acmserver.cs.ucr.edu/~nkumar/vision.htm -->
<HTML>
<HEAD><TITLE>Bankon Us</TITLE>
<body topmargin="0" leftmargin="0">
<tr>
<TD align=center>
<table cellpadding="0" cellspacing="0" border=0 width="100%">
<tr><td height="25"> </td></tr>
<tr>
<td width="50%" align="right">
<?php
$_SESSION['admfname']= $_POST['fname'];
$_SESSION['admlname']= $_POST['lname'];
$_SESSION['admpassword']=$_POST['password'];
if (($_SESSION['admfname'] == "peter") and ($_SESSION['admlname'] == "gewant") and ($_SESSION['admpassword'] == "approvalagent"))
{
echo "<meta http-equiv='Refresh' content='0; url=admin_page.php'>";
exit;
}
$f_name= $_POST['fname'];
$l_name= $_POST['lname'];
$pass= $_POST['password'];
if($_POST['submit'] != "Login")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgColor="#ff9900">
<form method="post" action="<?php $_SERVER['PHP_SELF']?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your<br> Account</td>
</tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/online.jpg"></td>
</tr>
</table>
<br><br>
<?php }
elseif($f_name== "" or $l_name== "" or $pass== "")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgcolor="#00CC99">
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your Account</td>
</tr>
<tr><td> </td></tr>
<tr><td colspan="3" align="center" class="heading">Please fill all the fields</td></tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/login1.jpg" width="300" height="200"></td>
</tr>
</table>
<?php
}
else {
$query = "SELECT * from helpagent WHERE first='$f_name' and last='$l_name' and password='$pass' ";
$result = mysql_query($query);
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$id = mysql_result($result, $i, "agentid");
$fname = mysql_result($result, $i, "first");
$lname = mysql_result($result, $i, "last");
$pas = mysql_result($result, $i, "password");
if (("$f_name" == "$fname") and ("$l_name" == "$lname") and ("$pass" == "$pas"))
{
$_SESSION['sfname'] = $f_name;
$_SESSION['slname'] = $l_name;
$_SESSION['sid'] = $id;
echo "<meta http-equiv='Refresh' content='0; url=user_page.php'>";
exit;
}//if loop
}//for loop
echo "<meta http-equiv='Refresh' content='0; url=new_user.php'>";
exit;
}
?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr>
<td>
<table border="0" width="100%">
<tr><td align="center" class="copy">Copyright © 2006 www.bankon.us All Rights Reserved</td></tr>
</table>
</td>
</tr>
</td>
</tr>
</table>
</BODY>
</HTML>[/php]
HI,
Are you including this file? or is this php script run directly? If you're including, then look into the parent file for the problem.
Are you sure you're updating the file on your remote server, maybe the file is still the old one with the error?
What are you using to edit your php file?
Have you tried editing the file directly on your server? Eg: using a shell access, or some web based control panel (Cpanel/Ensim etc.)
Reason youre getting this error:
sessions are implemented either as cookies or via the url. In your case, cookies, and the session cookie cannot be sent. A cookie is actually a http header.
HTTP headers need to be sent before HTTP Content (PHP output).
So some http content is already being sent somewhere... even though your script looks fine.
Are you including this file? or is this php script run directly? If you're including, then look into the parent file for the problem.
Are you sure you're updating the file on your remote server, maybe the file is still the old one with the error?
What are you using to edit your php file?
Have you tried editing the file directly on your server? Eg: using a shell access, or some web based control panel (Cpanel/Ensim etc.)
Reason youre getting this error:
sessions are implemented either as cookies or via the url. In your case, cookies, and the session cookie cannot be sent. A cookie is actually a http header.
HTTP headers need to be sent before HTTP Content (PHP output).
So some http content is already being sent somewhere... even though your script looks fine.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Jun 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 1
hi pls help me
this is my main file and i m running it directly
my problem is that i m using window xp and run php & mysql in it thr it run
but whn i run this file in linux server than these problems come
so there will be any problem of that
i have send u full file
i don't know from where some http content is sent
pls help me
this is my main file and i m running it directly
my problem is that i m using window xp and run php & mysql in it thr it run
but whn i run this file in linux server than these problems come
so there will be any problem of that
i have send u full file
i don't know from where some http content is sent
pls help me
•
•
Join Date: May 2006
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 0
Try removing blank lines from your html. I got this error a while back and this was the solution.
•
•
Join Date: Jun 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 1
Hi
I try wht u do but still i cann't run
this is my main file
and i m using notepad & dreamweaver for editing php
pls help me
i run this prog in my localhost thn it runs
my localhost is window xp
and whn i upload it in linux server thn the error comes
so pls help me
my boss is going 2 kill me if i cann't run this prog.
I try wht u do but still i cann't run
this is my main file
and i m using notepad & dreamweaver for editing php
pls help me
i run this prog in my localhost thn it runs
my localhost is window xp
and whn i upload it in linux server thn the error comes
so pls help me
my boss is going 2 kill me if i cann't run this prog.
•
•
•
•
Originally Posted by digital-ether
HI,
Are you including this file? or is this php script run directly? If you're including, then look into the parent file for the problem.
Are you sure you're updating the file on your remote server, maybe the file is still the old one with the error?
What are you using to edit your php file?
Have you tried editing the file directly on your server? Eg: using a shell access, or some web based control panel (Cpanel/Ensim etc.)
Reason youre getting this error:
sessions are implemented either as cookies or via the url. In your case, cookies, and the session cookie cannot be sent. A cookie is actually a http header.
HTTP headers need to be sent before HTTP Content (PHP output).
So some http content is already being sent somewhere... even though your script looks fine.
Ok...
Try this.
Open your script in notepad. (do not use dreamweaver).
Delete everything before the <?
Make sure <? is right at the top.
Then save the script as plain text. say "file.txt"
Upload it to your sever via ftp, don't use dreamweaver.
In ftp, rename your txt file back to the php extension.
Make sure you are uploading your files as binary. This can be done with most ftp programs.
Usually, if this is a problem with the upload, then the whole file should be "bad". But it just seems that the file on your Linux server, has some text added before the <?. So it could also be the editor, which is dreamweaver, so dont use it.
Try this.
Open your script in notepad. (do not use dreamweaver).
Delete everything before the <?
Make sure <? is right at the top.
Then save the script as plain text. say "file.txt"
Upload it to your sever via ftp, don't use dreamweaver.
In ftp, rename your txt file back to the php extension.
Make sure you are uploading your files as binary. This can be done with most ftp programs.
Usually, if this is a problem with the upload, then the whole file should be "bad". But it just seems that the file on your Linux server, has some text added before the <?. So it could also be the editor, which is dreamweaver, so dont use it.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- session variable error (PHP)
- Warning: session_start(): Cannot send session cache limiter - headers already sent (PHP)
- Need Help Correcting These errors (PHP)
- URL Redirection in PHP (PHP)
- Please Help Header Error (PHP)
- error message with sessions (PHP)
Other Threads in the PHP Forum
- Previous Thread: Session Login Problem
- Next Thread: Php Spacing


Linear Mode