1

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?

1 Answer 1

3

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;?>">
Sign up to request clarification or add additional context in comments.

3 Comments

It doesn't seem to have any effect but i have just noticed that this problem only applies to $id_post numbers under 10. It automatically puts a blank character before the number.
What is the data type of $id_post? If it is a string you can use trim to remove leading spaces.
Ok, now I can see my error, the $id_post had a blank space because on the main page there was still a blank space in my code, therefore all the other code carried that blank space afterwards, so your solution is absolutely correct! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.