Fixing the ampersand problem in PHP
Listed In PHP and MySQL » General Development — Viewing Full TutorialSessions are very useful until you start trying to code valid HTML or XHTML with PHP in them. You'll notice on all your links, PHP adds on PHPSESSID to the end, e.g. if you had something like:
<a href="yourpage.php">Click Here!</a>After PHP parsed it, it would become:<br />
<a href="yourpage.php?PHPSESSID=23487347612afb34234234h">Click Here!</a><br />Of course, this would be harmless to your valid document until you had an advanced navigation system, where you can't have 2 ?'s in the url and instead you have an ampersand (&).
For example:
<a href="?area=main&page=blah">Blah</a> is not valid, because the encoding would think that there is such HTML special charachter as &page=blah; and the W3C validator wouldn't like it.. <br /><br />
You first of all change all &'s to & (you could use find and replace if you have been graced with Dreamweaver) and second of all, on top of all your main PHP file (in avengex.com's case it's index.php because it includes stuff) add this code:<br />
<? ini_set("arg_separator.output", "&"); ?><br />
<br />Basically what this does is changes & to & - this has no effect on the URL but simply makes your document valid. You can be assured that this works if you click the XHTML valid button down the bottom right of the site where the buttons are!<br />
<br />
Anyway if you have any questions just comment.<br />
<br />
Will
