The error message told it all. Jochem was correct albiet not in the style I
prefer. I had the code in an HTML page after the header. I've been a
programmer for 15 years but I'm brand new to PHP. Anyone can make a rookie
mistake. Thanks everyone for the help. Everyone was partially correct in
assessing the problem.
Terry
"Eric Gorr" <mailist@xxxxxxxxxxxx> wrote in message
news:506F3853-DD28-4F71-A3DF-F9BB0A32AABF@xxxxxxxxxxxxxxx
On Sep 18, 2008, at 5:52 PM, Terry J Daichendt wrote:
I'm pasting this code from the example at php.net and getting these
errors. Can anyone determine what I'm doing wrong?
<?php
// page1.php
session_start();
echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
Well, this is weird. When I copied your text and tried it myself, the
error I got was:
Parse error: syntax error, unexpected T_STRING in /Users/ericgorr/
Sites/page1.php on line 9
Now, of course, there is nothing visibly wrong with line 9
($_SESSION['animal'] = 'cat';). But, when I had my text editor show
invisible characters, there were some on that line and line 10.
Do you have a text editor that can show invisible characters?
On the Mac, the one I really like (and is free) is TextWrangler
(http://www.barebones.com/products/textwrangler/ ) and has this
capability. This may be part of your problem. Once I got rid of the
invisible characters, the example worked without any problems.
Also, are you certain there are no spaces or anything (even invisible
characters) before <?php?
Whenever I've gotten a similar error in the past, that was nearly always
the problem. You are welcome to compress the text file and send it to me
directly so I can see exactly what it contains.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php