473,883 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

embedded php snippet won't parse/validate in XHTML

I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^

When the browser hits the < after value, it thinks I'm starting another
tag before I finish my input tag. Fair enough. I switch the <'s for
$lt; and then it stops here:

<input type="text" name="ud_first" id="ud_first"
value="&lt;? echo "$first"?&g t;" />
-------------------^

Switching the $ to $ doesn't help.

I can get this page to work if I change it to a .php file instead of
..xhtml. That can't be my only option?!?

Mark

Jan 1 '07 #1
5 3956
Hello,

ma************@ gmail.com wrote:
I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^

When the browser hits the < after value, it thinks I'm starting another
tag before I finish my input tag. Fair enough. I switch the <'s for
$lt; and then it stops here:

<input type="text" name="ud_first" id="ud_first"
value="&lt;? echo "$first"?&g t;" />
-------------------^

Switching the $ to $ doesn't help.

I can get this page to work if I change it to a .php file instead of
.xhtml. That can't be my only option?!?
Did you try the original file (with ...value="<? echo "$first"?>" ...) with
a .php extension?

The server is probably not configured to pass .xhtml through the PHP
interpreter, so it serves the PHP source code (which is not (X)HTML and
cannot be parsed as such).
You can only validate the output generated by PHP, not the PHP source code.

HTH

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/
Jan 1 '07 #2
At 06:57:33 on Mon, 1 Jan 2007, ma************@ gmail.com wrote in
<11************ **********@k21g 2000cwa.googleg roups.com>:
>I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^
You've nested your double-quotes, but the parser doesn't know that. Try
value="<? echo '$first'?>" or value='<? echo "$first"?>'
--
Molly Mockford
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety - Benjamin Franklin
(My Reply-To address *is* valid, though may not remain so for ever.)
Jan 1 '07 #3
Dan

ma************@ gmail.com wrote:
I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^
PHP isn't supposed to validate directly as HTML or XHTML. It contains
code that is supposed to be parsed and executed at the server end,
producing output that then goes on to the user agent to be rendered or
validated, with no sign of the PHP code remaining.

--
Dan

Jan 1 '07 #4
..oO(ma******** ****@gmail.com)
>I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^

When the browser hits the < after value, it thinks I'm starting another
tag before I finish my input tag. Fair enough. I switch the <'s for
$lt; and then it stops here:
The browser should never see that code, because it has to be executed on
the server.
>I can get this page to work if I change it to a .php file instead of
.xhtml. That can't be my only option?!?
Configure the server to parse .xhtml files for PHP. And consider to use
<?php instead of <?, short open tags are unreliable.

Micha
Jan 3 '07 #5
Rik
ma************@ gmail.com wrote:
I have an "Update Customer" form that doesn't work as .xhtml. Here's
where it stops working:

<input type="text" name="ud_first" id="ud_first"
value="<? echo "$first"?>" />
-------^

When the browser hits the < after value,
As explained it shouldn't hit that. Your php code will be useless at least.
it thinks I'm starting
another tag before I finish my input tag. Fair enough. I switch the
<'s for $lt; and then it stops here:

<input type="text" name="ud_first" id="ud_first"
value="&lt;? echo "$first"?&g t;" />
-------------------^

Switching the $ to $ doesn't help.
Well, encoding the " would be more rewarding, but still your php is
useless.
About the php: Why put <? echo "$first";?? ??? <? echo $first; ?(or even
better <?php echo $first; ?>) seems more appropriate to put it lightly.
I can get this page to work if I change it to a .php file instead of
.xhtml. That can't be my only option?!?

Nope. You will have to parse it as php offcourse, or remove the
php-snippets from the code. You've got the very unattractive option to tell
your web server to parse every .html, .xhtml, or .whatsinaname through php,
but it will result in a large unwanted overhead and load on the server, not
to mention it's hardly portable. Possible, but I'd strongly advise against
it.

A better question is: why do you want the .xhtml extension? If it's just
about 'friendlier' urls: the actual filenames can have very little to do
with the urls. Look at mod_rewrite for apache and the like.
--
Rik Wasmus
Jan 3 '07 #6

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

Similar topics

2
2122
by: Rick | last post by:
Hi.. I've got some code I wrote in PHP that will generate a new argument string for the browser, but the xhtml parser in Firefox and Opera both complain about my use of &var=value pairs. Below is my code that generates the string : function InvokeURL(url_to_forward_to) { try {
1
3002
by: Julius Mong | last post by:
Dear all, I have something like this: <html... > <embed ...> </html> Am I out of luck if I wanted to access the embedded DOM and manipulate its content? Or if I have:
4
3174
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a particular tag, and was also pretty sure that they wanted the following <ul><li>two</li><li>items</li></ul> to appear as a list. To make matters worse <sarcastic>how could this be worse?</sarcastic>, the XHTML can be mixed with our own tags.</note>
22
4773
by: Haines Brown | last post by:
I have a document with a set of internal links such as: <a name="Z1"></a>... <a name="Z2"></a>... The W3C validator objects to the first instance of the name attribute: There is no attribute "FOO" for this element (in this HTML version). The element is defined not to have this attribute. These anchors are not contained in anything. For example, the Z1
5
2358
by: Zhang Weiwu | last post by:
Hello. I just read a article "rdf in html: approaches" at "http://infomesh.net/2002/rdfinhtml" (guided by google). Looking into the "Embed XML RDF Part II: Embrace Validation" part, there are an example DTD and xhtml page. I don't know much about xhtml Modularization, but I think this example should be workable in cut-and-paste fashion for newcomers to use. In fact I copied the example xhtml file into my website, it won't pass...
2
1575
by: Rick | last post by:
Hi.. I've got some code I wrote in PHP that will generate an HTML page with embedded javascript which in turn creates a new argument string for the browser, but the xhtml parser in Firefox and Opera both complain about my use of &var=value pairs in the generated URL. Below is my code that generates the string, and is part of an embedded HTML page (generated on the fly by a PHP script): function InvokeURL(url_to_forward_to) {
8
7435
by: Spartanicus | last post by:
The document at http://homepage.ntlworld.com/spartanicus/custom_dtd.htm uses a custom DTD, the w3c validator validates it but with this warning: "Unknown Parse Mode! The MIME Media Type (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode."...
1
1842
by: pstephen01010101 | last post by:
I've ran out of debugging ideas. If anyone knows why this won't run in IE 6 please let me know. It works fine in Fire Fox 2.0.0.3 and Netscape (version unknown). I suspect there is something basic about IE and Javascript that I'm wholly unaware of. I've edited the HTML code to include just the essential elements because it exceeded the allowed word count. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
5
2440
by: ioni | last post by:
Good day, fellows! I have a strange problem – at my site there is a flash strip, that loads data dynamically. It works fine (grabs data from the remote server and presents it), however in IE7 and its clones I encounter a strange problem where I can hear clicking sound non-stop (like the page is being reloaded non- stop), whereas the page is not reloading.
0
9797
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10763
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10863
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7978
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5807
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6006
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.