ahs10 Posted March 16, 2009 Share Posted March 16, 2009 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! Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/ Share on other sites More sharing options...
JonnoTheDev Posted March 16, 2009 Share Posted March 16, 2009 & 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 Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-785917 Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 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> Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-785919 Share on other sites More sharing options...
ahs10 Posted March 16, 2009 Author Share Posted March 16, 2009 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. Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-786153 Share on other sites More sharing options...
JonnoTheDev Posted March 16, 2009 Share Posted March 16, 2009 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 Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-786160 Share on other sites More sharing options...
ahs10 Posted March 16, 2009 Author Share Posted March 16, 2009 k, thanks... i didn't know if i was being lazy or not i did find something that works. it's borderline stupid, but it works... <?php echo $_GET['amp;var']; ?> thanks for the thoughts yall. have a great day, cheers! Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-786166 Share on other sites More sharing options...
rhodesa Posted March 16, 2009 Share Posted March 16, 2009 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 Link to comment https://forums.phpfreaks.com/topic/149658-php-_get-doesnt-understand-amp-how-do-i-validate/#findComment-786220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.