473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Valid XHTML with PHP sessions?

OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from the
use_trans_sid setting after script execution):

....
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
....

Which throws errors like:

Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

and

Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #1
16 2515
On Wed, 28 Jul 2004 16:56:29 +0000, Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from the
use_trans_sid setting after script execution):

...
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
...

Which throws errors like:

Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

and

Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?

Justin, I haven't tested this and something simply off the top of my
head.. have you tried making your HTML something like:
<form ...><div>
[ form elements here ]
</div></form>
I don't know what routine PHP uses when inserting the session ID into a
form area other than it appears to add it to a newline under the <form>
initiation line. Hoping that it kind of "ignores" the <div> after <form>,
it'll end up dumping the hidden element into the <div> area which will
allow for valid XHTML (<form> is not a container etc etc)

It may be that, PHP actually checks for the entire <form...> tag and
inserts the hidden field directly after it inwhich case the above idea
would obviously fail, but it's something I'd try myself if you haven't
already. Would be interested to hear the results of this if you do try it =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2
Ian.H wrote:
On Wed, 28 Jul 2004 16:56:29 +0000, Justin Koivisto wrote:

OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from the
use_trans_sid setting after script execution):

...
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
...

Which throws errors like:

Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

and

Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?
Justin, I haven't tested this and something simply off the top of my
head.. have you tried making your HTML something like:

<form ...><div>
[ form elements here ]
</div></form>


It is. Everything about the page is valid, except when useing trans-sid.
I turned it off to be sure...
I don't know what routine PHP uses when inserting the session ID into a
form area other than it appears to add it to a newline under the <form>
initiation line. Hoping that it kind of "ignores" the <div> after <form>,
it'll end up dumping the hidden element into the <div> area which will
allow for valid XHTML (<form> is not a container etc etc)

It may be that, PHP actually checks for the entire <form...> tag and
inserts the hidden field directly after it inwhich case the above idea
would obviously fail, but it's something I'd try myself if you haven't
already. Would be interested to hear the results of this if you do try it =)


Nope. PHP replaces '<form ...>' with '<form ...><input... />' - even if
there is a DIV element after the FORM start tag.

It's not just the form elements... In anchor tags, if you have something
like:

<a href="/?group=3">group 3</a>

it's changed to:

<a href="/?group=3&PHPSESSID=djf8fdjrigkv7eru4i4ei8h3r9f5n"> group 3</a>

It uses "&" instead of "&amp;", and since it's done *after* script
execution, there isn't a way to simply do a preg_replace on the output
buffer. :\

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #3
On Wed, 28 Jul 2004 17:17:48 GMT, Justin Koivisto <sp**@koivi.com> wrote:
It's not just the form elements... In anchor tags, if you have something
like:

<a href="/?group=3">group 3</a>

it's changed to:

<a href="/?group=3&PHPSESSID=djf8fdjrigkv7eru4i4ei8h3r9f5n"> group 3</a>

It uses "&" instead of "&amp;", and since it's done *after* script
execution, there isn't a way to simply do a preg_replace on the output
buffer. :\


Just set arg_separator.output correctly and you're sorted.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #4
On Wed, 28 Jul 2004 16:56:29 GMT, Justin Koivisto <sp**@koivi.com> wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from the
use_trans_sid setting after script execution):

...
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
...

Which throws errors like:

Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag
<form> isn't a container. The <input> tag needs to be contained within a
grouping tag. Don't use <div>, use <fieldset> instead for more meaningful
HTML.
Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?


I tried inserting that <a> tag in my own XHTML Strict pages and they still
validated fine.

What I'm guessing is that it isn't the "/statistics/?PHPSESSID=..." links
it's complaining about, but those where there are extra GET variables like
"/statistics/?id=4&PHPSESSID=..." where the validator would try to make
PHPSESSID into an html entity and fail.

Do you have a URI we could look at?

Grey

--
The technical axiom that nothing is impossible sinisterly implies the
pitfall corollory that nothing is ridiculous.
- http://www.greywyvern.com - Orca Knowledgebase: Completely CSS styleable
Knowledgebase/FAQ system
Jul 17 '05 #5
In article <0d*****************@news7.onvoy.net>, Justin Koivisto wrote:
Ian.H wrote:
I don't know what routine PHP uses when inserting the session ID into a
form area other than it appears to add it to a newline under the <form>
initiation line. Hoping that it kind of "ignores" the <div> after <form>,
it'll end up dumping the hidden element into the <div> area which will
allow for valid XHTML (<form> is not a container etc etc)


If you search this group, or the php bug database (think #13472) you'll
find workarounds...

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #6
Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...
Not hard. Mine validates to XHTML 1.1 Strict and with a change of doctype
most pages also validate to XHTML 1.0 Strict and XHTML 1.0 Basic. If a
dolt like me can do it, I'm sure you can.
Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag
You've probably done something like:
<form><input/></form>

You need something nested between the <form> and <input> elements -- some
kind of block element. For example:

<form><fieldset><input/></fieldset></form>
Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"


You have a URL with an '&' sign in it. Replace the '&' with '&amp;'.

Both of these are errors in HTML 4.01 too -- it's not just XHTML that's
causing you problems.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Now Playing ~ ./william_shatner_-_common_people_sample.ogg

Jul 17 '05 #7
Andy Hassall wrote:
On Wed, 28 Jul 2004 17:17:48 GMT, Justin Koivisto <sp**@koivi.com> wrote:

It's not just the form elements... In anchor tags, if you have something
like:

<a href="/?group=3">group 3</a>

it's changed to:

<a href="/?group=3&PHPSESSID=djf8fdjrigkv7eru4i4ei8h3r9f5n"> group 3</a>

It uses "&" instead of "&amp;", and since it's done *after* script
execution, there isn't a way to simply do a preg_replace on the output
buffer. :\

Just set arg_separator.output correctly and you're sorted.


GREAT! (I knew there had to be something for that one...)

Now if I can just get the form thing fixed...

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #8
GreyWyvern wrote:
On Wed, 28 Jul 2004 16:56:29 GMT, Justin Koivisto <sp**@koivi.com> wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from
the use_trans_sid setting after script execution):

...
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
...

Which throws errors like:

Line 48, column 139: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag


<form> isn't a container. The <input> tag needs to be contained within
a grouping tag. Don't use <div>, use <fieldset> instead for more
meaningful HTML.


Good tip, it has been changed to fieldset.
Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?


I tried inserting that <a> tag in my own XHTML Strict pages and they
still validated fine.

What I'm guessing is that it isn't the "/statistics/?PHPSESSID=..."
links it's complaining about, but those where there are extra GET
variables like "/statistics/?id=4&PHPSESSID=..." where the validator
would try to make PHPSESSID into an html entity and fail.

Do you have a URI we could look at?


Not that I can publish here... However, this part has been corrected now
with the setting of arg_separator.output to "&amp;" via .htaccess.

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #9
Toby Inkster wrote:
Justin Koivisto wrote:
Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag


You've probably done something like:
<form><input/></form>


Not me, PHP... but only when session.use_trans_sid = 1 and the client
doesn't have cookies...
Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"


You have a URL with an '&' sign in it. Replace the '&' with '&amp;'.


Solved by setting arg_separator.output to "&amp;"... it was PHP, not the
code (that validates just fine).

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #10
Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...


For why?

--
Charles Sweeney
http://CharlesSweeney.com
Jul 17 '05 #11
On Wed, 28 Jul 2004 17:17:48 +0000, Justin Koivisto wrote:
[ snip ]

I don't know what routine PHP uses when inserting the session ID into a
form area other than it appears to add it to a newline under the <form>
initiation line. Hoping that it kind of "ignores" the <div> after <form>,
it'll end up dumping the hidden element into the <div> area which will
allow for valid XHTML (<form> is not a container etc etc)

It may be that, PHP actually checks for the entire <form...> tag and
inserts the hidden field directly after it inwhich case the above idea
would obviously fail, but it's something I'd try myself if you haven't
already. Would be interested to hear the results of this if you do try it =)


Nope. PHP replaces '<form ...>' with '<form ...><input... />' - even if
there is a DIV element after the FORM start tag.

Good to hear the anchor side of things is sorted Justin.. but the above is
a little of a bitch =\ Other than Tim's suggestion of reading the bugs DB,
not sure what to offer as a solution (I haven't read the bugs DB regarding
this either..... yet =) ).

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #12
Charles Sweeney wrote:
Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...


For why?


shits & giggles really...

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #13
Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1

What is happening is the validator (that doesn't use cookies) sees
things like the following in the source (which are put in there from the
use_trans_sid setting after script execution):

...
<a href="/statistics/?PHPSESSID=1423fa4c27d130ea743ffd9912f60de4">
...

Which throws errors like:

Line 48, column 139: document type does not allow element "input" here;
missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre",
"address", "fieldset", "ins", "del" start-tag

and

Line 66, column 194: cannot generate system identifier for general
entity "PHPSESSID"

Anyone have any hints or pointers to correct this?


OK, the form's hidden input part of the problem (from my .htaccess file):

php_value url_rewriter.tags
"a=href,area=href,frame=src,input=src,fieldset=fak eentry"

The anchor tag part:
php_value arg_separator.output "&amp;"

Hope this helps someone!

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Jul 17 '05 #14
Justin Koivisto wrote:
Charles Sweeney wrote:
Justin Koivisto wrote:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...


For why?


shits & giggles really...


As good a reason as any Mr K.

--
Charles Sweeney
http://CharlesSweeney.com
Jul 17 '05 #15
Never doubted you for a moment!

--
Charles Sweeney
http://CharlesSweeney.com
Jul 17 '05 #16
Justin Koivisto <sp**@koivi.com> wrote in message news:<1V*****************@news7.onvoy.net>...
OK, on my quest to get one PHP site that is actually valid XHTML 1.0
(strict)...

PHP 4.3.8: session.use_trans_sid=1


<snip>

http://www.google.com/search?q=cache...Fsession+xhtml

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shyamal Prasad | last post by:
Hi, Is there anyway to write JSP files as valid HTML of any sort. What I want to know is if JSP files are some sort of valid XML with a DTD that will check contents. Perhaps JSP files are valid...
5
by: Greg | last post by:
Hi everybody, so, I would like to use XML files for some parts of my website. I would like to respect W3C XHTML 1.1 recommendation. Then, I have these two docs : o My XML file: <?xml...
1
by: Anna | last post by:
Hi all. I have probably a rather stupid question. If there is an HTML document, XML-formed using JTidy, is there any tool to convert it to valid XHTML? I.e. so that all the tags and attribute...
38
by: Jukka K. Korpela | last post by:
As well all know, valid markup is important... but when trying to find a convincing modern argument in favor of this, I found pages like http://www.htmlhelp.com/tools/validator/reasons.html which...
18
by: Neal | last post by:
According to the specs (http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to 4.01, it won't validate,...
12
by: thomas_jedenfelt_1 | last post by:
Hi everyone, Is the W3C HTML Validator in error when it returns <br /> as valid for HTML 4.01 Strict doctype? In March 2004 , the Validator returned <br />, <hr /> and <img /> as invalid for...
8
by: Anthony Williams | last post by:
Morning all, I'm having a wee problem with a project I'm working on at the moment. I'm leading my company into producing a website, based upon Web Standards, which will be created using XHTML...
9
by: Brian Lowe | last post by:
I'm using Visual Studio to build ASP.Net pages and I'm trying to be standards compliant by using XHTML. In my page I create valid XHTML such as: <ul> <li>first list item</li> <li>second list...
4
by: Lee Chapman | last post by:
Hi, I am having difficulty getting the ASP.NET framework to generate valid XHTML. My immediate problem surrounds user input in, for example, textbox controls. I consider characters such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.