Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

W3C error validating - Bad value for attribute href on element a: Illegal character in query: not a URL code point

I get the bad value for attribute href on element a: Illegal character in query: not a URL code point on W3C with the following a tag:

<a href="/edit_booking.php?requestID=84&amp;moduleID=109&amp;no_rooms=2&amp;parks=Central,East&amp;rooms=1,39&amp;weeks=1,3,5,7,9,11,13,15&amp;day=1&amp;semester=1&amp;start_time=09:00&amp;end_time=10:00&amp;length=1&amp;students=100&amp;type=Lecture&amp;Priority=N&amp;metaID=&amp;comments=Crappy Booking&amp;status=1&amp;round=1&amp;date_submitted=2015-02-16 05:01:17&amp;year=2015/2016&amp;" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>

The link is generated from PHP; now if the commas are not allowed I can do a replace but I'm not sure if they are allowed in this format or not.

Is there something I'm missing, because it looks fine to me?

like image 490
mdixon18 Avatar asked Feb 16 '15 06:02

mdixon18


2 Answers

The spaces in the query string are causing the error. In your sample they appear in two places: comments=Crappy Booking and date_submitted=2015-02-16 05:01:17.

URL-encoding the spaces to %20, as advised by the validator, allows your markup to validate:

<a href="/edit_booking.php? ... &amp;comments=Crappy%20Booking&amp;status=1&amp;round=1&amp;date_submitted=2015-02-16%2005:01:17&amp;year=2015/2016&amp;" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>
like image 150
BoltClock Avatar answered Nov 10 '22 14:11

BoltClock


Using PHP, rawurlencode will do the job (percent-encoding) for you.

A space will be encoded to %20 (RFC 3986).

like image 45
ixany Avatar answered Nov 10 '22 14:11

ixany