urlencode() breaks URL?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

urlencode() breaks URL?

Post by LiveFree »

Hey Again,

In the effort to make my blog project core-code totally 100% Valid XHTML (Trans.) I have begun to use urlencode() for links generated with variables for ex:

Code: Select all

$entries.= "<font size='1'><i>Catagory: <a href='#'>$cat_name</a> | Published: $date | ID: $id | # of Comments: <a href='" . $_SERVER['PHP_SELF'] . "?op=view_comment&id=$id" . "'>$num</a></i></font>\n";
Of course that code DOES NOT pass the validation, citing these errors:

cannot generate system identifier for general entity "id".

...'/PostBlog/index.php?op=view_comment&id=1'>2</a></i></font>


But when I add the urlencode( before the $_SERVER and the ) after the $id", I get a 404 not found error even though the path shown on the 404 error matches what it would be without the urlencode

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

tried switching & to &?
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

Ah,
That did it feyd! Thanks :)
Post Reply