![](/img/trans.png)
[英]bad value for attribute "action" on element "form": illegal charachter in path segment: "<" is not allowed
[英]Validation Error: Bad value for attribute href on element a: Illegal character in query: not a URL code point
我正在提取數據庫信息並將其顯示在表中,標題列的內容鏈接到動態頁面。 一切正常,但是使用W3C驗證程序驗證輸出頁面時,出現以下錯誤,不知道如何解決!
錯誤值newpage.php?url =元素a的屬性href的數據庫信息:查詢中的非法字符:不是URL代碼點。
然后,它突出顯示a href“>”的結束標記。
<?php
echo"<table>
<tr>
<th>Title</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
</tr>
</table>";
if (mysqli_num_rows($SQLresult) == 0 )
{
echo 'No results found, please try again.';
}
else
{
while ($row = mysqli_fetch_assoc($SQLresult))
{
echo "
<table>
<tr>
<td><a href='newpage.php?url=".$row['title']."'>".$row['title']."</td>
<td>".$row['A']."</td>
<td>".$row['B']."</td>
<td>".$row['C']."</td>
<td>".$row['D']."</td>
</tr>
</table>";
}
}
?>
任何幫助將不勝感激,謝謝。
並非所有字符在URL中都是合法的。 那些不合法的可以使用百分號和兩個十六進制數字重新編碼。 PHP的urlencode()
函數可以做到這一點。 在要成為鏈接的部分上使用urlencode()
。
$url = urlencode($row['title']);
...
<td><a href='newpage.php?url=".$url."'>".$row['title']."</td>
或者,您可以這樣做:
<td><a href='newpage.php?url=".urlencode($row['title'])."'>".$row['title']."</td>
您可以在RFC2396中的URL / URI中找到有關合法字符的更多信息: https : //tools.ietf.org/html/rfc2396#section-2
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.