Log in

View Full Version : Inline PHP not validating.



dallr
11-21-2008, 02:57 AM
Hello all, I have some php which is not validating at W3C (http://validator.w3.org/#validate_by_input).

For example one of the messages points me to this line.

Warning Line 60, Column 83: character "<" is the first character of a delimiter but occurred as data.

…>User Name <input type="text" value="<?php echo $_SESSION['username']; ?>" id

It seems like it is failing where the inline php starts i.e "<" .

Does anyone know how to solve this.

Dallr

Nile
11-21-2008, 04:10 AM
Try this:


<input type="text" value="<?=$_SESSION['username'];?>"...

That should work, if it doesn't then ignore it it's just a bug in they're validation. If you were to post this online[http://example.com] and validated that it wouldn't see it. So you can just replace the value with the real value just to get the badge, then change it back and when people click on your badge it will show up as valid because the validation can't see PHP (because it's not open source).

JasonDFR
11-21-2008, 02:22 PM
Hi,

I think there must be something else wrong with your code somewhere.

I do the same thing you are doing all the time and have never had a problem with W3C validation.

Post all of the compiled code (the code you get when you "view source" in your browser). Or tell me the url of this page.

J