BrianJHightower wrote:
> Hello,
> I have been following the Dreamweaver 8 Dynamic
Development from Lynda.com.
> He builds an Admin system in ColdFusion. I'm using PHP.
I'm not familiar with that Lynda.com course, but trying to
learn how to
build a PHP site with a course written for ColdFusion is like
trying to
read Italian with only a knowledge of French - doable, but
not advisable.
> 2 issues I have been struggling with.
>
> First Question) The pages will ask for the password, and
take me to the
> requested page. After that, the session appears to be
destroyed.
> Second Question) I am getting header errors, and I know
where from.
Both questions are related. If you get header errors, you
won't be able
to access session variables on the page.
> The problem is this code at the beginning:
> Code:
>
> <?php virtual('/Connections/Hostgator_Highwade.php');
?>
> <?php
> if (!isset($_SESSION)) {
> session_start();
> }
There are several possible reasons for getting header errors.
First of
all, I should point out that Dreamweaver uses virtual()
because you have
set your site definition to use links relative to the site
root. This
works only on Apache, and will fail on all other servers. If
you're
using Apache, you're OK, but if you're using any other
server, you
should switch your site definition to use links relative to
the
document. This uses include(), which is universally supported
by PHP
servers.
What causes header problems is any output to the browser
before the call
to session_start(). If you're getting any error messages,
that will be
the cause of your problem. Other causes are whitespace at the
top of the
page (before the opening PHP tag) and any whitespace before
the opening
PHP tag or after the closing one in your connections file.
There must be
nothing outside the tags - not even a new line.
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/