Jump to content

Recommended Posts

in my js i had url's like "whatever.php?id=1&var=0"

 

because of the ampersand the html markup wouldn't validate so i used the entity &

 

this broke the php script reading the var with $_GET['var'], i guess php doesn't recognize & as an ampersand?  how do i get my html markup to validate and php to work properly.

 

thanks!

& is not a valid url parameter. you must use & in order for values to be passed.

 

page.php?a=1&b=2&c=3

 

print $_GET['c'];

 

Use php to validate data instead of javascript. If javascript is disabled then your data will never be validated

it should look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <p><a href="whatever.php?id=1&var=0">Test</a></p>
  </body>
</html>

thanks for the reply guys.

 

rhodesa - that won't work, if this were the contents of whatever.php -

<?php
echo $_GET['var'];
?>

you would have a blank page :(

 

neil - you are correct, i understand the & is not a valid url parameter and php will not recognize it.  i think perhaps i didn't explain myself well though.  i would like to validate my html markup.... with w3c.  i can't figure out how to be able to pass get variables to outside php scripts and still have valid html markup.

 

 

The fact is whatever.php?id=1&var=0 is a valid url. Forget any HTML validator as you are not passing html through urls.

What I would recommend would be to rewrite these urls using mod_rewrite making them search engine friendly.

An example of

/whatever.php?id=1&var=0

/whatever/1/0

um...what browser are you using? and do you have a link to the page so i can see it? cus the following on my page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Test</title>
  </head>
  <body>
    <p><a href="whatever.php?id=1&var=123">Test</a></p>
  </body>
</html>

and in whatever.php:

<?php
print $_GET['var'];
?>

prints '123' for me

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.