Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

W3C errors on PHP URL String variables

Explorer ,
May 09, 2017 May 09, 2017

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.

At
line 108, column 67

.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?

2.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2017 May 09, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 09, 2017 May 09, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2017 May 09, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2017 May 09, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2017 May 09, 2017

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...>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2017 May 09, 2017

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 > ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 09, 2017 May 09, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2017 May 09, 2017

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

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2017 May 15, 2017

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.

Hope this clarifies things.   With the above change, The problem is now solved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2017 May 15, 2017
LATEST

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.

Hope this clarifies things.   With the above change, The problem is now solved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines