Re: Error message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux