Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HTML链接正在破坏超链接_Php_Mysql_Html Entities - Fatal编程技术网

Php HTML链接正在破坏超链接

Php HTML链接正在破坏超链接,php,mysql,html-entities,Php,Mysql,Html Entities,我正试着做一些有趣的事情。然而,超链接现在被破坏了,因为它们被转换成html代码,出于愚蠢的原因,大学给了我们所有服务器相同的密码 去年,我几乎失败了,因为有人进入我的服务器,并充满了javascript和css攻击,所以这将阻止它,但如果超链接不起作用,这并没有多大用处,所以我如何防止这种情况?以下是我迄今为止针对该特定领域的代码: $sub = substr($row['content'],0,300).'.......... <a href="blogpost.php?id='.$r

我正试着做一些有趣的事情。然而,超链接现在被破坏了,因为它们被转换成html代码,出于愚蠢的原因,大学给了我们所有服务器相同的密码

去年,我几乎失败了,因为有人进入我的服务器,并充满了javascript和css攻击,所以这将阻止它,但如果超链接不起作用,这并没有多大用处,所以我如何防止这种情况?以下是我迄今为止针对该特定领域的代码:

$sub = substr($row['content'],0,300).'.......... <a href="blogpost.php?id='.$row['id'].'">See full article</a>';
echo htmlentities($sub,ENT_QUOTES,"UTF-8");
$sub=substr($row['content'],0300)。”;
echo Htmlenties($sub,ENT_报价,“UTF-8”);

如果有人能提供帮助,我们将不胜感激,谢谢。

我认为您在太多的输出上应用了
htmlentities()
。就这样做吧:

<?php echo htmlentities(substr($row['content'],0,300)).
           '&hellip;<a href="blogpost.php?id="'.htmlentities($row['id']).'">See full article</a>'; ?>

我认为您在太多输出上应用了
htmlentities()
。就这样做吧:

<?php echo htmlentities(substr($row['content'],0,300)).
           '&hellip;<a href="blogpost.php?id="'.htmlentities($row['id']).'">See full article</a>'; ?>

不要在整个链接上应用
htmlentities
,而是在实际要转义的值上应用,如下所示

$sub = htmlentities(substr($row['content'],0,300), ENT_QUOTES, 'UTF-8') . '.......... <a href="blogpost.php?id=' . htmlentities($row['id'], ENT_QUOTES,'UTF-8') .'">See full article</a>';
echo $sub;
$sub=htmlentities(substr($row['content'],0300),ENT_引号,'UTF-8');
echo$sub;

不要在整个链接上应用
htmlentities
,而是在实际要转义的值上应用,如下所示

$sub = htmlentities(substr($row['content'],0,300), ENT_QUOTES, 'UTF-8') . '.......... <a href="blogpost.php?id=' . htmlentities($row['id'], ENT_QUOTES,'UTF-8') .'">See full article</a>';
echo $sub;
$sub=htmlentities(substr($row['content'],0300),ENT_引号,'UTF-8');
echo$sub;

您的预期产出是什么?您得到了什么?请重新表述您的问题好吗?在我添加htmlentities之前,这是代码
echo substr($row['content',0300)。”
这将正常输出超链接,以便您可以单击它并进入请求的页面,现在它只输出超链接,如下所示输出!。。。。。。。。。。在连接之前,为什么不在
substr($row['content',0300)
$row['id']
上单独使用
htmlentities
?……OMFG@Uours,我甚至都没有想到:/going to go go go go to go to go…。你期望的输出是什么,你得到了什么?你能重新表述你的问题吗?在我添加htmlentities之前,这是代码
echo substr($row['content',0300)。”
这将正常输出超链接,以便您可以单击它并进入请求的页面,现在它只输出超链接,如下所示输出!。。。。。。。。。。为什么你不在连接之前单独使用
htmlentities
substr($row['content'],0300)
$row['id']
?……OMFG@Uours,我甚至没有想到:/going to go to go…哇。几秒钟真的可以改变一切D:哇。几秒钟真的可以改变D: