LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-28-2005, 01:48 AM   #1
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Rep: Reputation: 30
php session - works with warning !!!


Hello everybody,
To test propagation of session, I have three scripts:

idnex.php:
Code:
<html>
<head><title>abc</title></head>
<center><h1>abc</h1></center>
<body bgcolor="pink">
 <form action="user_auth.php" method="post">
   User Name:<input type="text" name="user_name"/><br /><br />
   Password :<input type="password" name="password"/><br /><br />
   <input type="submit" name="submit" />
 </form>
 </body>
</html>

user_auth.php:
Code:
<html>
<head></head>
<body bgcolor="pink">
<?php
  session_start();
  $_SESSION['user']=$_POST['user_name'];
  $_SESSION['passwd']=$_POST['password'];
  $link=mysql_connect("localhost",$_SESSION['user'],$_SESSION['passwd']);
  mysql_select_db("pali");
  $result=mysql_query("select * from wll");
  echo "<table border=\"2\">";
  while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
    {
      echo "\t<tr>\n";
      foreach ($line as $col_value) 
       {
        echo "\t\t<td>$col_value</td>\n";
       }
      echo "\t</tr>\n";
    }
  echo "</table>";
  mysql_free_result($result);
  mysql_close($link)
?>
  <form action="ex.php" method="post">
  <input type="submit">
  </form>
</body>
</html>
When I go from the first page to the second page, following warnings are issued:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/user_auth.php:4) in /var/www/html/user_auth.php on line 5

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/user_auth.php:4) in /var/www/html/user_auth.php on line 5

Then the output is produced.

Why are there warnings ?
Can anyone tell me ?


Thanks in advance.

Last edited by prabhatsoni; 05-28-2005 at 01:56 AM.
 
Old 05-28-2005, 02:14 AM   #2
juanbobo
Member
 
Registered: Mar 2005
Location: Chicago
Distribution: Gentoo AMD64
Posts: 365

Rep: Reputation: 30
Put the session_start() before any html?
 
Old 06-02-2005, 11:45 PM   #3
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
Thannk you Mr Juanbobo for help. It works now

Prabhat Soni
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GnomeUI WARNING While connecting to session manager RayJ Linux - Newbie 8 01-05-2009 05:34 PM
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
PHP Warning: Unable to load dynamic library xbaez Linux - Software 3 02-15-2005 06:11 PM
php session richard22 Programming 2 10-26-2004 05:50 AM
PHP Warning: Unknown(): imap: Unable to initialize module dude4you Linux - Software 2 03-01-2004 11:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration