php-general Digest 25 Dec 2003 01:09:11 -0000 Issue 2492
Topics (messages 173294 through 173313):
Removing/unsetting session variables.
173294 by: Alain Williams
173295 by: CPT John W. Holmes
173305 by: Matt Grimm
Re: Error with Absolute URLs
173296 by: CPT John W. Holmes
Re: Headers Problem
173297 by: Beauford
173298 by: CPT John W. Holmes
173299 by: Beauford
No <? or <?php in Windows
173300 by: Robin Kopetzky
173301 by: CPT John W. Holmes
array data to XML
173302 by: Chakravarthy Cuddapah
173304 by: Matt Grimm
173308 by: Manuel Lemos
Cannot Access Includes Above Current Directory if using SSL
173303 by: Steve Benson
173306 by: Steve Benson
apache/web site question...
173307 by: bruce
173309 by: Matt Grimm
[Q] Compatibility issues using Apache and/or IIS
173310 by: Michael T. Peterson
session problems across pages
173311 by: obsidianchrysalis
basic set and read a cookie probs
173312 by: Jack E. Wasserstein, DDS, Inc.
programming the onclick() event in an anchor
173313 by: Peter Walter
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I have several variables that I set in a session - to record that a user is logged in.
I want to be able to unset them - when they log out.
$_SESSION['PERMS_USER'] = 'fred';
Sets the variable quite nicely, I can also change it and the change is recorded.
I cannot unset it. I have tried (in various combinations):
unset($_SESSION['PERMS_USER']);
unset($HTTP_SESSION_VARS['PERMS_USER']);
session_unregister($SESSION['PERMS_USER']);
session_unregister($HTTP_SESSION_VARS['PERMS_USER']);
None of which have any effect.
What should I do ?
Thanks
Merry Christmas.
--
Alain Williams
#include <std_disclaimer.h>
FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org
--- End Message ---
--- Begin Message ---
From: "Alain Williams" <[EMAIL PROTECTED]>
> I have several variables that I set in a session - to record that a user
is logged in.
> I want to be able to unset them - when they log out.
>
> $_SESSION['PERMS_USER'] = 'fred';
> Sets the variable quite nicely, I can also change it and the change is
recorded.
> I cannot unset it. I have tried (in various combinations):
>
> unset($_SESSION['PERMS_USER']);
unset is what you should use. How do you know it's "not working"??
---John Holmes...
--- End Message ---
--- Begin Message ---
PHP manual recommends this, which works for me:
// Unset all of the session variables
$_SESSION = array();
// Destroy the session
session_destroy();
--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: [EMAIL PROTECTED]
Web: www.healthtvchannel.org
"Alain Williams" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have several variables that I set in a session - to record that a user
is logged in.
> I want to be able to unset them - when they log out.
>
> $_SESSION['PERMS_USER'] = 'fred';
> Sets the variable quite nicely, I can also change it and the change is
recorded.
> I cannot unset it. I have tried (in various combinations):
>
> unset($_SESSION['PERMS_USER']);
> unset($HTTP_SESSION_VARS['PERMS_USER']);
> session_unregister($SESSION['PERMS_USER']);
> session_unregister($HTTP_SESSION_VARS['PERMS_USER']);
>
> None of which have any effect.
>
> What should I do ?
>
> Thanks
>
> Merry Christmas.
>
> --
> Alain Williams
>
> #include <std_disclaimer.h>
>
> FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
> best interests of our children. See http://www.fathers-4-justice.org
--- End Message ---
--- Begin Message ---
From: "Brad" <[EMAIL PROTECTED]>
> I keep getting errors on my websites, that contain absolute URLs, e.g.
> http://www.url.com/blah.html. With most, being in the folder of my
> website, it's fine, i can just add $_SERVER['DOCUMENT_ROOT'], but
> there's a script I use to display the network statistics of an IRC
> network, which is located on a different server, so i can't use the
> $_SERVER['DOCUMENT_ROOT'], I'm wondering if anyone has an answer to
> this. I'm almost to the stage of just asking the script owner if I can
> have it located locally, so i can use the $_SERVER['DOCUMENT_ROOT']
> variable.
Ummm... if the page you're linking to isn't on your server, then you need to
hard code the link to that page. If your "script" automatically uses
$_SERVER['DOCUMENT_ROOT'] for every URL that's created, then you need to
rewrite that "script". That's the "solution".
---John Holmes...
--- End Message ---
--- Begin Message ---
Beauford wrote:
> I'm getting the following error. My question is, where would I use the
> ob_start() and ob_end_flush() function so I can get rid of this. I
> have read the PHP manual, but not quite getting it.....Or if there is a
better way?
> Don't work around the problem with output buffering; try fixing it.
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at
> /usr/local/apache/htdocs/supreme/updates/update-corrections-write.php:
> 2) in /usr/local/apache/php/includes/restricted.inc on line 1
You must have session_start() before any output. You've placed it on line 1
of restricted.inc, but output was started on line 2 of
update-corrections-write.php. If you're going to include restricted.inc and
start a session, include it before there is output.
Just a clarification, session_start() is on the first line of restricted.inc
and restricted.inc is included on the first line of
update-corrections-input.php. All update-corrections-write.php does is write
info to a database and includes update-corrections-input.php on the last
line. So I'm still not understanding where the output from
update-corrections-write.php is coming from.
Thanks
--- End Message ---
--- Begin Message ---
From: "Beauford" <[EMAIL PROTECTED]>
> Just a clarification, session_start() is on the first line of
restricted.inc
> and restricted.inc is included on the first line of
> update-corrections-input.php. All update-corrections-write.php does is
write
> info to a database and includes update-corrections-input.php on the last
> line. So I'm still not understanding where the output from
> update-corrections-write.php is coming from.
Sounds like you have a blank line as the first line in
update-corrections-write.php. If "<?php" isn't the very first thing in the
file, then this isn't going to work.
---John Holmes...
--- End Message ---
--- Begin Message ---
Yes, there was a blank line. Now I just have to test it to see if that was
it. One other question though. It appears that Windows does not have this
problem - the site in question is on a Linux box. Why would this be? The two
sites are identical, I just use the Windows one for developing and testing.
I have looked at both php.ini files, and other than the OS specific stuff,
they are the same as well.
Thanks again...
-----Original Message-----
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
Sent: December 24, 2003 8:52 AM
To: Beauford
Cc: 'PHP'
Subject: Re: [PHP] Headers Problem
From: "Beauford" <[EMAIL PROTECTED]>
> Just a clarification, session_start() is on the first line of
restricted.inc
> and restricted.inc is included on the first line of
> update-corrections-input.php. All update-corrections-write.php does is
write
> info to a database and includes update-corrections-input.php on the
> last line. So I'm still not understanding where the output from
> update-corrections-write.php is coming from.
Sounds like you have a blank line as the first line in
update-corrections-write.php. If "<?php" isn't the very first thing in the
file, then this isn't going to work.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Good Morning and Merry Christmas to all.
I recently installed PHPTriad to a new server and the <? and <?php tags do
not work on ANY html page. Does anyone know what I may have missed in
configuration? Help...
Thanks a million in advance.
Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020
--- End Message ---
--- Begin Message ---
From: "Robin Kopetzky" <[EMAIL PROTECTED]>
> Good Morning and Merry Christmas to all.
>
> I recently installed PHPTriad to a new server and the <? and <?php tags do
> not work on ANY html page. Does anyone know what I may have missed in
> configuration? Help...
Try using them on a .php page? PHP doesn't normally run on plain HTML files
(with an .html or .htm extension).
---John Holmes...
--- End Message ---
--- Begin Message ---
newbie ...
Is it possible to format data in array to XML and display ?
Thanks !
--- End Message ---
--- Begin Message ---
Of course. If it's a simple (short) array, you can just create a string
with the XML tags and array values, and write that to a file with an XML
extension.
More sexy would be to use the DOMXML functions in PHP.
http://us3.php.net/manual/en/ref.domxml.php
Guy named Kris wrote a great XML -> PHP script that you can find here,
although it may be more than you are looking for:
http://www.devdump.com/phpxml.php
I've written a DOMXML-based PHP -> XML function that takes Kris' structure
as input, if you're interested.
--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: [EMAIL PROTECTED]
Web: www.healthtvchannel.org
"Chakravarthy Cuddapah" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
newbie ...
Is it possible to format data in array to XML and display ?
Thanks !
--- End Message ---
--- Begin Message ---
Hello,
On 12/24/2003 02:44 PM, Chakravarthy Cuddapah wrote:
Is it possible to format data in array to XML and display ?
This class seems to do what you want. It requires DOM XML extension.
Class: XML Array
http://www.phpclasses.org/xmlarray
You may also want to try this class for generating XML documents without
requiring any extension:
Class: XML Writer class
http://www.phpclasses.org/xmlwriter
--
Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
I'm new to your list and configuring Apache with the SSL module enabled
and have a newbie configuration glitch I've not been able to resolve.
I'm very puzzled over why my scripts with included files, either SSI or
PHP, work fine outside of the SSL directory structure (but still at
similar nested levels in directory tree but not SSL). i.e.
given that /www/sd/htdocs/include/middle.html exists
with index.shtml in /www/sd/htdocs/test (http) with the lines
<!--#include file="../include/middle.html" --> and
<!--#echo var="DOCUMENT_NAME" --> run fine and middle.html is included
and the document name is displayed. Excellent!
But the same index.shtml in /www/sd/htdocs/jobs (https) <!--#include
file="../include/middle.html" --> fails to include middle.html and the
error_log file reports: unable to include file
"/www/sd/htdocs/include/middle.html" in parsed file
/www/sd/htdocs/jobs/index.shtml Not problem with <!--#echo
var="DOCUMENT_NAME" --> the document name is displayed. Only half
excelent.
I changed the SSI to <!--#include virtual="../include/middle.html" -->
as you suggested but the result was the same. I changed the relative
path used to absolute and also got the same result. I can use includes
in the SSL directory as long as they're at the same level or below. If I
move the above example (including the include directory) down one level
in the https directory tree i.e. given that
/www/sd/htdocs/jobs/include/middle.html exists with index.shtml in
/www/sd/htdocs/jobs/test (https) <!--#include
file="../include/middle.html" --> it also fails. So I can't go up even
within the https directory tree. The same scenario under http presents
no problems.
The SSI is mostly for testing trying to figure out why my PHP scripts
are acting this way. I'm trying to keep it simple so I can find the root
cause of my SSL (https) virtual server failure to work with upper level
include files.
i.e.
given that /www/sd/htdocs/include/prepend.php exists
<?php
include("../include/prepend.php");
....
?>
So, if I try the above code from a https directory, say
/www/sd/hddocs/jobs it will fail with:
PHP Warning: main(../include/prepend.php): failed to open stream: No
such file or directory in /www/sd/htdocs/jobs/index.php on line 4
Using an absolute path rather than a relative path has no effect. I even
tried a scriptalias clause, same as /cgi-bin/ but /include/ to the
include files dir, but that didn't work either.
There is no problem if I change the include location to
/www/sd/htdocs/jobs/include, I can run the scripts fine. So it seems I
can include at the same level or below but not up any level in the
directory tree if using https.
I imagine there's something in my SSL configuration causing this but
after trying many <Directory>, <Location> and even a ScriptAlias changes
to the ssl.conf I've not been able to get around this.
I've created a number of Apache web sites but this is my first using
SSL(mod_ssl incorporated into Apache 2.0.48, openssl). I've never
encountered anything like this before in web development.
My configuration is:
RH Linux Kernel 2.4.20-8, Apache 2.0.48, OpenSSL -0.9.6l, PHP 4.3.4
(compiled as a mod w/Apache), Apache was compiled with SSL and SSI
enabled. SSL appears to work OK i.e. recognized by browser, cert and key
accepted etc.
To summarize:
- All scripts work fine with relative paths to include files as long as
they're accessed via http and are not in the https virtual server
directory tree structure.
- When accessing the same scripts within the https virtual server tree
the scripts cannot reference any include files that aren't at the same
level or below in the directory tree.
- If the include file is made available at the same level or below, no
problem accessing via relative or absolute paths.
- Even when the paths to include files are changed to absolute paths
they fail if the file is above the current directory in the tree
(https). For some reason I can't go up the directory tree from within
the https virtual server directory structure. This is true no matter
where I am in the structure i.e. if I'm two levels deep in the directory
tree I can't reference a file up one level. If I'm three levels deep I
can't reference files back on level two, bummer!
I appreciate any suggestions.
Thanks,
............ Steve
--- End Message ---
--- Begin Message ---
I'm new to your list and configuring Apache with the SSL module enabled
and have a newbie configuration glitch I've not been able to resolve.
I'm very puzzled over why my scripts with included files, either SSI or
PHP, work fine outside of the SSL directory structure (but still at
similar nested levels in directory tree but not SSL). i.e.
given that /www/sd/htdocs/include/middle.html exists
with index.shtml in /www/sd/htdocs/test (http) with the lines
<!--#include file="../include/middle.html" --> and
<!--#echo var="DOCUMENT_NAME" --> run fine and middle.html is included
and the document name is displayed. Excellent!
But the same index.shtml in /www/sd/htdocs/jobs (https) <!--#include
file="../include/middle.html" --> fails to include middle.html and the
error_log file reports: unable to include file
"/www/sd/htdocs/include/middle.html" in parsed file
/www/sd/htdocs/jobs/index.shtml Not problem with <!--#echo
var="DOCUMENT_NAME" --> the document name is displayed. Only half
excelent.
I changed the SSI to <!--#include virtual="../include/middle.html" -->
as you suggested but the result was the same. I changed the relative
path used to absolute and also got the same result. I can use includes
in the SSL directory as long as they're at the same level or below. If I
move the above example (including the include directory) down one level
in the https directory tree i.e. given that
/www/sd/htdocs/jobs/include/middle.html exists with index.shtml in
/www/sd/htdocs/jobs/test (https) <!--#include
file="../include/middle.html" --> it also fails. So I can't go up even
within the https directory tree. The same scenario under http presents
no problems.
The SSI is mostly for testing trying to figure out why my PHP scripts
are acting this way. I'm trying to keep it simple so I can find the root
cause of my SSL (https) virtual server failure to work with upper level
include files.
i.e.
given that /www/sd/htdocs/include/prepend.php exists
<?php
include("../include/prepend.php");
....
?>
So, if I try the above code from a https directory, say
/www/sd/hddocs/jobs it will fail with:
PHP Warning: main(../include/prepend.php): failed to open stream: No
such file or directory in /www/sd/htdocs/jobs/index.php on line 4
Using an absolute path rather than a relative path has no effect. I even
tried a scriptalias clause, same as /cgi-bin/ but /include/ to the
include files dir, but that didn't work either.
There is no problem if I change the include location to
/www/sd/htdocs/jobs/include, I can run the scripts fine. So it seems I
can include at the same level or below but not up any level in the
directory tree if using https.
I imagine there's something in my SSL configuration causing this but
after trying many <Directory>, <Location> and even a ScriptAlias changes
to the ssl.conf I've not been able to get around this.
I've created a number of Apache web sites but this is my first using
SSL(mod_ssl incorporated into Apache 2.0.48, openssl). I've never
encountered anything like this before in web development.
My configuration is:
RH Linux Kernel 2.4.20-8, Apache 2.0.48, OpenSSL -0.9.6l, PHP 4.3.4
(compiled as a mod w/Apache), Apache was compiled with SSL and SSI
enabled. SSL appears to work OK i.e. recognized by browser, cert and key
accepted etc.
To summarize:
- All scripts work fine with relative paths to include files as long as
they're accessed via http and are not in the https virtual server
directory tree structure.
- When accessing the same scripts within the https virtual server tree
the scripts cannot reference any include files that aren't at the same
level or below in the directory tree.
- If the include file is made available at the same level or below, no
problem accessing via relative or absolute paths.
- Even when the paths to include files are changed to absolute paths
they fail if the file is above the current directory in the tree
(https). For some reason I can't go up the directory tree from within
the https virtual server directory structure. This is true no matter
where I am in the structure i.e. if I'm two levels deep in the directory
tree I can't reference a file up one level. If I'm three levels deep I
can't reference files back on level two, bummer!
I appreciate any suggestions.
Thanks,
............ Steve
--- End Message ---
--- Begin Message ---
hi...
a very basic (i hope) question...
i know i can have a web page that uses PHP/ASP/Etc... and i can do a kind of
include, such that i can incorporate content/text from another file. i'm
curious to know if there is a way to do that such that i can incorporate
text from a file on another server on a separate domain/IP address???
any examples/sample pages demonstrating this would be helpful!!!
I would like to be able to accomplish this from within the apache httpd.conf
file if possible, where i simply define a website/page and the httpd.conf
directive points to the file on the separate PC..... If this isn't possible,
I'll take the PHP/ASP/Etc.. approach where I can include a file that resides
on another completely different server/PC...
thanks...
bruce douglas
[EMAIL PROTECTED]
(925) 866-2790
--- End Message ---
--- Begin Message ---
"As long as allow_url_fopen is enabled in php.ini, you can use HTTP and FTP
URLs with most of the functions that take a filename as a parameter. In
addition, URLs can be used with the include(), include_once(), require() and
require_once() statements."
http://us4.php.net/manual/en/features.remote-files.php
--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: [EMAIL PROTECTED]
Web: www.healthtvchannel.org
"Bruce" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hi...
>
> a very basic (i hope) question...
>
> i know i can have a web page that uses PHP/ASP/Etc... and i can do a kind
of
> include, such that i can incorporate content/text from another file. i'm
> curious to know if there is a way to do that such that i can incorporate
> text from a file on another server on a separate domain/IP address???
>
> any examples/sample pages demonstrating this would be helpful!!!
>
> I would like to be able to accomplish this from within the apache
httpd.conf
> file if possible, where i simply define a website/page and the httpd.conf
> directive points to the file on the separate PC..... If this isn't
possible,
> I'll take the PHP/ASP/Etc.. approach where I can include a file that
resides
> on another completely different server/PC...
>
> thanks...
>
> bruce douglas
> [EMAIL PROTECTED]
> (925) 866-2790
>
>
--- End Message ---
--- Begin Message ---
First I'm very new to all this, so forgive the naivity of these questions:
Anyway, I am building a WEB Site dev environment that supports PHP-MySQL
development. I have both IIS and Apache WEB servers available for local
testing which begs the following question:
What are the factors that would influence my choosing IIS over Apache or
vice-versa? If I develop and test against a local Apache server, will I run
into problems when uploading to a site that uses IIS? What about using a
local IIS server and uploading to an Apache site?
Thanks in advance.
Michael
--- End Message ---
--- Begin Message ---
thanks for the help, it definitely saved my from hours of pulling at me
hairs.
however i have a new problem. i can create session variables, but i can't
access them across pages.
for example.
page2.php
Code:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
echo "<strong>Step 2 - Register Session </strong><br />";
// Get the user's input from the form
$name = $_POST['name'];
// Register session key with the value
$_SESSION['name'] = $name;
// Display the sssion information:
?>
Welcome to my website <strong><? echo $_SESSION['name']; ?></strong>!<br />
Let's see what happens on the <a href="page3.php">next page.</a><br /><br />
page3.php
Code:
<?php
// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<strong>Step 3 - test Session Part II </strong><br />
Hey <strong><? echo $_SESSION['name']; ?></strong> Everything is still
working!<br /><br />
<strong>Pick an option:</strong><br />
Let's delete this session value now. <a href="page4.php">Click Here.</a><br
/>
Let's destroy this session. <a href="page5.php">Click Here.</a><br /><br />
on page2.php (after the _SESSION['name'] variable is set with a form on
another page) the value of the variable comes up fine. however on page3.php,
the value is blank. any thoughts why? i tried tinkering with the php.ini
(v.4.0 on a Win98 box) but nothing changed.
--- End Message ---
--- Begin Message ---
I am using the following code on the php form handler
if ($_POST[referdrremember] == "true") {
setcookie("remailcookie",
"$_POST_VARS[refdremail]",time()+3600,"/","wasserstein.com","0");
Try to see the cookie in the same script, not sure which one to use with or
without $
print " the cookie's value is $HTTP_COOKIE_VARS[remailcookie] ";
print " the cookie's value is 2 $HTTP_COOKIE_VARS[$remailcookie] ";
In addition when I get back to the calling form and refresh it I try to see
the cookie with this:
if ($HTTP_COOKIE_VARS[remailcookie]) {
print ("remail cookie exists"); }
else {
print ("no cookie");
}
This yeilds "no cookie"
I have also tried $_COOKIE[] as well
What am I doing wrong.
Thanks in advance,
Jack
--- End Message ---
--- Begin Message ---
I have written a session-enabled php page which displays a table of
search results. The first column in the table contains anchor links to
www.mydomain.com/mypage?seqno=xxxx where seqno is a variable I would
like to pass when the anchor is clicked. However, I do not wish the
?seqno=xxxx to display in the url of the browser. After googling a lot,
it appears that I can use JavaScript to set a session variable in the
onclick() event, but I have not been able to find an example of how to
do it. Does anyone have experience doing this? Sample code would be
greatly appreciated.
Peter
--- End Message ---