W3C errors on PHP URL String variables
Copy link to clipboard
Copied
I have designed a Real Estate webpage that has over 100 URL Links that pass to another page for a database table query. The page works but when I run a W3C check on the page I get errors. see below for the error from W3C check.
=
in
an unquoted attribute value. Probable causes: Attributes running
together or a URL query string in an unquoted attribute value.
.php?company_id
=
010002&id=1000
Here is the complete line of code. As I said, the code as written below works, but produces W3C check errors.
How can I re-write this code so it passes the W3C check.
Here is the existing line of code:
<a
href="http://mlsonlinecr.com/mlshomesforsale_page.php?company_id=010002&type=%25&city=%25&province=%25&sub...">Homes</a></li>
<li><a
href="http://mlsonlinecr.com/mlshomesforsale_page.php?
Copy link to clipboard
Copied
You cannot.
The W3C checker can only check html or css code, and flags anything else as an error. To check your html or css then you will have to do this before inserting the php code, or ignore errors that you know are php code.
Copy link to clipboard
Copied
Just to be clear, the W3C checker does not see your PHP code, unless the code is not correctly contained within code tags.
You may want to use the PHP functions urlencode and urldecode on your urls to make sure the urls don't contain anything that will break. I do see a blank space in provin ce, which would be a problem.
Copy link to clipboard
Copied
Rob, thanks for the reply. The space in pro vince is not in the code. It happened when I copied and pasted. Do you have any examples of using the urlencode on the strings. The webpage that I am working on is located at this link. The example that I included in the forum is in the TOP Navbar "HOMES": Real Estate, Costa Rica Baby Boomers
Copy link to clipboard
Copied
You are missing the ending double quotes in several of your links href attributes. For example...
<a href=http://www.mlsonlinecr.com/mlshomesdetail.php?company_id=010002&id=10004&submit=Search>
...needs a " right before the ending >
It looks like pretty much all of that style of link in the page are missing the quote at the end.
Copy link to clipboard
Copied
I had copied the line of code to a text editor and it deled some of the quotes. Below is the line of code direct from Dreamweaver 2017.
<li><a href="http://mlsonlinecr.com/mlshomesforsale_page.php?company_id=010002&type=%25&city=%25&province=%25&sub...>
Copy link to clipboard
Copied
The code I pasted above is copied from your website. Here's the code online as viewed with my Firefox browser, note each red line is missing the closing " before the > ...
Copy link to clipboard
Copied
There are lots of places you can learn about using urlencode, such as at php.net
I have no need for it myself because all my urls are constructed from sanitized and validated variables that don't include things like quotation marks, spaces or special characters.
Copy link to clipboard
Copied
As PZ said, W3C validation is useless on raw PHP code. You need to check the Live Code.
Assuming you have a local PHP development environment set-up in CC 2017, open your PHP document. Go to View > Live Code. This will parse the PHP code and display the document as one would see it in a browser on the server.
Go to Window > Results > Validation.
Click the triangle to check Live Document. See screenshot.
Nancy
Copy link to clipboard
Copied
Maybe I did not clearly explain the problem. I continued to work on a solution and have now resolved the problem.
Here is the old URL Link that worked on the page, but produced a W3C error (online w3c check of the host page) followed by the new link that uses php variables for the string variables.
- Link that has W3C error: <a href="http://mlsonlinecr.com/mlshomesforsale_page.php?company_id=010002&type=%25&city=%25&province=%25">Homes</a>
- Link that has NO W3C errors and sucessfully links to the URL: <a href="http://mlsonlinecr.com/mlshomesforsale_page.php<?php echo "?company_id=" . $company_id . "&type=" . $all_values . "%25&city=" . $all_values . "&province=" . $all_values ; ?>">Homes</a>
Hope this clarifies things. With the above change, The problem is now solved.
Copy link to clipboard
Copied
Maybe I did not clearly explain the problem. I continued to work on a solution and have now resolved the problem.
Here is the old URL Link that worked on the page, but produced a W3C error (online w3c check of the host page) followed by the new link that uses php variables for the string variables.
- Link that has W3C error: <a href="http://mlsonlinecr.com/mlshomesforsale_page.php?company_id=010002&type=%25&city=%25&provin ce=%25">Homes</a>
- Link that has NO W3C errors and sucessfully links to the URL: <a href="http://mlsonlinecr.com/mlshomesforsale_page.php<?php echo "?company_id=" . $company_id . "&type=" . $all_values . "%25&city=" . $all_values . "&province=" . $all_values ; ?>">Homes</a>
Hope this clarifies things. With the above change, The problem is now solved.

