I certainly read your reply and tried it with the session_start as the first
line of the php secion. I have since remove the HTML etc.   The script
appears to work with out error .

I was able to set session vars etc and the script completed with out error
and the session vars could be printed out at the end of the script.

I then called another php script from my menu frame and was not able to find
the _session vars which showed as blanks. I put the session_start() as first
line of php block but this still did not make it possible to read the
session vars.

Do I need to use names sessions or what?  Is there some setting that is
required in the php.ini or apache to make this work?


As I stated at the beigining of the e-mail saga what i want to be able to do
is to set global variables which will be available to any php script. In
particular i want to ensure that each user has an individual connection to
data abse and that this is maintained through out the session. I have set
the connection up to use the mysql_pconnect function, but I still need to
reconnect in every script which uses the database.  I therefore need to be
able to caryy the username/password from onepage to the next.

Is the start_session and session variables the corect way to do this or is
there a better way?

Regards

Peter Goggin
----- Original Message -----
From: "John Holmes" <[EMAIL PROTECTED]>
To: "'Peter Goggin'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, June 02, 2002 3:31 PM
Subject: RE: [PHP] Apache, html, php and global variables


> Did you read my reply at all? Call session_start() before any output to
> the browser.
>
> ---John Holmes...
>
> > -----Original Message-----
> > From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, June 02, 2002 1:20 AM
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: Re: [PHP] Apache, html, php and global variables
> >
> > My script is:
> > <html>
> > <body>
> > <?php
> > session_start();
> > printf("<P> loggin on as ");
> > printf ("<P>user name: ");
> > printf ($HTTP_POST_VARS['User']);
> > printf ("<P>Password: ");printf ($HTTP_POST_VARS['Password']);
> > printf ("<P>");
> >
> >
> >     /* Connecting, selecting database */
> >     $link = mysql_pconnect("localhost", $HTTP_POST_VARS['User'],
> > $HTTP_POST_VARS['Password'])
> >         or die("Could not connect");
> >     print "Connected successfully<P>";
> >     printf ("<BR>");
> >     print "Setting Global variables<BR>";
> >     $_SESSION_VARS["dbauser"]=($HTTP_POST_VARS['User']);
> >     $_SESSION_VARS["dbapassword"]=($HTTP_POST_VARS['Password']);
> >     printf ($_SESSION_VARS["dbauser"]);
> >     printf ("<BR>");
> >     printf ($_SESSION_VARS["dbapassword"],"<BR>");
> > ?>
> > <P>
> > </body>
> > </html>
> >   The errors I get are:
> > Warning: Cannot send session cookie - headers already sent by (output
> > started at c:\usr\www\my-domain\databaselogin.php:3) in
> > c:\usr\www\my-domain\databaselogin.php on line 4
> >
> > Warning: Cannot send session cache limiter - headers already sent
> (output
> > started at c:\usr\www\my-domain\databaselogin.php:3) in
> > c:\usr\www\my-domain\databaselogin.php on line 4
> >
> > loggin on as
> >
> > user name: stampuser
> >
> > Password: vantwest
> >
> > Connected successfully
> >
> >
> > Obviously I have something not configured correctly, or I am calling
> the
> > function in the wrong place.  Any advice on how to overcome this would
> be
> > very useful.
> >
> >
> > Regards
> >
> >
> > Peter Goggin
> >
> > ----- Original Message -----
> > From: "John Holmes" <[EMAIL PROTECTED]>
> > To: "'Peter Goggin'" <[EMAIL PROTECTED]>; <php-
> > [EMAIL PROTECTED]>
> > Sent: Sunday, June 02, 2002 12:09 AM
> > Subject: RE: [PHP] Apache, html, php and global variables
> >
> >
> > > Sessions use cookies, which use headers, which have to be sent
> before
> > > any output. <html> is output. So, put session_start() before that.
> > >
> > > <?
> > > Session_start();
> > >
> > > ...
> > >
> > > ?>
> > > <html>
> > > <body>
> > > ...
> > >
> > > Where are you putting dbauser and dbapassword into the session?
> > >
> > > Your sessions still aren't going to work because the
> session.save_path
> > > isn't set correctly in your PHP.ini. Set it to a directory on your
> > > computer that the web server has access to write to.
> > >
> > > ---John Holmes...
> > >
> > > > -----Original Message-----
> > > > From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> > > > Sent: Saturday, June 01, 2002 9:54 AM
> > > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > > > Subject: Re: [PHP] Apache, html, php and global variables
> > > >
> > > > I am not clear what you mean by this. I have set session_start()
> on in
> > > the
> > > > php script that logs onto the database initially.  i then call a
> test
> > > php
> > > > script from a button on the menu frame. This is the output it
> gives:
> > > >
> > > > Test php variables
> > > >
> > > > Warning: Cannot send session cookie - headers already sent by
> (output
> > > > started at c:\usr\www\my-domain\maintenance.php:4) in
> > > > c:\usr\www\my-domain\maintenance.php on line 5
> > > >
> > > > Warning: Cannot send session cache limiter - headers already sent
> > > (output
> > > > started at c:\usr\www\my-domain\maintenance.php:4) in
> > > > c:\usr\www\my-domain\maintenance.php on line 5
> > > >
> > > > Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR)
> > > failed:
> > > > No
> > > > such file or directory (2) in c:\usr\www\my-domain\maintenance.php
> on
> > > line
> > > > 5
> > > > Test of global variables
> > > > DBA USER:
> > > > DBA Password;
> > > > Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR)
> > > failed:
> > > > No
> > > > such file or directory (2) in Unknown on line 0
> > > >
> > > > Warning: Failed to write session data (files). Please verify that
> the
> > > > current setting of session.save_path is correct (/tmp) in Unknown
> on
> > > line
> > > > 0
> > > >
> > > >
> > > > The script is:
> > > > <HTML>
> > > > <BODY>
> > > > Test php variables<BR>
> > > > <?php
> > > > session_start();
> > > >     printf ("Test of global variables<BR>");
> > > >     printf ("DBA USER: ",$_SESSION_VARS["dbauser"],"<BR>");
> > > >     printf ("<BR>");
> > > >     printf ("DBA Password;
> ",$_SESSION_VARS["dbapassword"],"<BR>");
> > > > ?>
> > > > </BODY>
> > > > </HTML>
> > > >
> > > > Is there a problem with how I am using sessiot_start, or is there
> a
> > > php
> > > > config problem?
> > > >
> > > > Regards
> > > >
> > > > Peter Goggin
> > > >
> > > > ----- Original Message -----
> > > > From: "John Holmes" <[EMAIL PROTECTED]>
> > > > To: "'Peter Goggin'" <[EMAIL PROTECTED]>; <php-
> > > > [EMAIL PROTECTED]>
> > > > Sent: Saturday, June 01, 2002 2:04 PM
> > > > Subject: RE: [PHP] Apache, html, php and global variables
> > > >
> > > >
> > > > > You still have to connect to a database every time a script is
> run,
> > > > > whether it's loaded in a frame or run by itself. If you start a
> > > session
> > > > > and save the username and password in it, then you can use that
> > > login
> > > > > and password on every other page that you call session_start()
> on.
> > > > >
> > > > > ---John Holmes...
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> > > > > > Sent: Friday, May 31, 2002 11:12 PM
> > > > > > To: [EMAIL PROTECTED]
> > > > > > Subject: Re: [PHP] Apache, html, php and global variables
> > > > > >
> > > > > > I am not certain how this helps me, since it appears the data
> is
> > > only
> > > > > > carried to pages called directly from where it is set.  The
> page
> > > where
> > > > > the
> > > > > > user logs onto the database does not link to other pages. This
> is
> > > done
> > > > > > from
> > > > > > the top frame of the form. The top frame of the inital page
> > > contains
> > > > > the
> > > > > > menu, one option of which is to log onto the data base to
> start a
> > > > > session.
> > > > > > The user will then select another page from the top form.
> > > > > >
> > > > > > This new page is displayed in the bottom frame of the intial
> page,
> > > and
> > > > > > there
> > > > > > may be futher links within this page on the bottom
> fram.Generally
> > > > > however
> > > > > > main navigation is from the top frame which remains in place
> > > through
> > > > > out.
> > > > > > What I wabt to do is to have the login information available
> at
> > > all
> > > > > times
> > > > > > once the user is logged in, nomattar how the current page is
> > > called.
> > > > > >
> > > > > > Is this possible?
> > > > > >
> > > > > > If so how is this done?
> > > > > >
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Stuart Dallas" <[EMAIL PROTECTED]>
> > > > > > To: <[EMAIL PROTECTED]>
> > > > > > Sent: Saturday, June 01, 2002 11:56 AM
> > > > > > Subject: Re: [PHP] Apache, html, php and global variables
> > > > > >
> > > > > >
> > > > > > > On Saturday, June 1, 2002 at 2:42:40 AM, you wrote:
> > > > > > > > Is there any way of caryying the login information from
> one
> > > web
> > > > > page
> > > > > > to
> > > > > > the
> > > > > > > > next in global variables so that the username and password
> > > entered
> > > > > in
> > > > > > the
> > > > > > > > login screen is available to all other web pages in the
> site
> > > or do
> > > > > I
> > > > > > have to
> > > > > > > > ask the user to re-enter this information at every screen?
> > > > > > >
> > > > > > > Sessions: http://www.php.net/session
> > > > > > >
> > > > > > > --
> > > > > > > Stuart
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > PHP General Mailing List (http://www.php.net/)
> > > > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > PHP General Mailing List (http://www.php.net/)
> > > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > >
> > > > > --
> > > > > PHP General Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to