Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 25th, 2005, 05:23 PM
Authorized User
 
Join Date: Apr 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing variables through session

Hi,

I am working on the Beginning php,mysql and apache book, chapter 2. I am having problems passing a value through a session.
I have typed the code exactly as it say in the book and I keep getting this error:

Warning: Cannot send session cookie - headers already sent by (output started at c:\phpdev\www\phppractise\music review site\movie1.php:2) in c:\phpdev\www\phppractise\music review site\movie1.php on line 3

Warning: Cannot send session cache limiter - headers already sent (output started at c:\phpdev\www\phppractise\music review site\movie1.php:2) in c:\phpdev\www\phppractise\music review site\movie1.php on line 3
Click here to see information about my favorite movie!

I am not sure what is happening here. Can anyone help?

I have checked the php.ini file for the correct session_save_path which seems to be pointing to the right file.

Any ideas whats wrong?

David

Reply With Quote
  #2 (permalink)  
Old April 26th, 2005, 06:08 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

See http://p2p.wrox.com/topic.asp?TOPIC_ID=29730

Reply With Quote
  #3 (permalink)  
Old April 28th, 2005, 02:05 PM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the above does not work it could just be a silly problem such as whitespace. You would want to have your <?php in the beginning of your page (no whitespace before it), start your session and whatever php coding, then close it with ?> before you write your <html> tag.

For example:
<?php
session_start();
//php coding here...
?>
<html>
<head></head>
<body></body>
</html>

Reply With Quote
  #4 (permalink)  
Old April 29th, 2005, 10:14 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, but I have done exactly as you said and it still does'nt work.

I have copied the code exactly as it says in the book:

move1.php-<?php
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
     $myfavmovie=urlencode("Life of Brian");
     echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>";
     echo "Click here to see information about my favorite movie!";
     echo "</a>";
?>
</BODY>
</HTML>

Moviesite.php-<?php
$_SESSION['username']="Joe12345";
$_SESSION['authuser']=1;
?>
<HTML>
<HEAD>
<TITLE>Find my Favorite Movie!</TITLE>
</HEAD>
<BODY>
<?php
     $myfavmovie=urlencode("Life of Brian");
     echo "<a href='http://localhost/moviesite.php?favmovie=$myfavmovie'>";
     echo "Click here to see information about my favorite movie!";
     echo "</a>";
?>
</BODY>
</HTML>

I have checked register globals is off and that the php.ini file is pointing to the right temp file for sessions, which is all ok!

It is becoming a bit of a problem now because I really don't know what to do and I can't progress in the "beginning php,mysql and apache" book until I resolve this problem, as sessions are required for the examples in the book.

Wish I new what the problem is???

Many thanks
David







Reply With Quote
  #5 (permalink)  
Old May 4th, 2005, 10:35 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put
session_start();

at the beginning of your pages...

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing session variables from login page. captainzorro Classic ASP Components 1 April 23rd, 2008 11:54 PM
Passing session variables from IIs to Tomcat aman thaper Internet Information Services 0 November 14th, 2006 09:34 AM
Passing Session Variables to the Next Page jim.sullivan@telus.net ASP.NET 1.0 and 1.1 Professional 1 August 1st, 2004 06:25 PM
Passing Session Variables to the Next Page jim.sullivan@telus.net Classic ASP Databases 2 August 1st, 2004 01:59 PM



All times are GMT -4. The time now is 01:48 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.