简体   繁体   中英

W3C validation Illegal character in query: not a URL code point

The w3C validator has found an error in my HTML:

Bad value comment_add.php?id= 7 for attribute action on element form: Illegal character in query: not a URL code point.

It marked the closing ">" tag as a problem

<form method="post" action="comment_add.php?id= 7"**>**

The code which generated that HTML is:

<form method="post" action="comment_add.php?id=<?= $id_post;?>">

I have a few other lines with the same issue.

How can I solve this problem?

There should not be any spaces in the action of the form.

You should change your code to:

<form method="post" action="comment_add.php?id=<?=$id_post;?>">

If you need a space in your URL is should be encoded as %20 . So the code would then look like:

<form method="post" action="comment_add.php?id=%20<?=$id_post;?>">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM