php - 结束标签与结束标签冲突
问题描述
<?php
$query="SELECT * FROM Products ORDER BY id ASC";
$result=mysqli_query($connect,$query);
$image_path = "";
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_array($result))
{
?>
<div class="item" style="background:white;solid lightgrey;box-shadow: 12px 12px 22px -10px #888888;">
<form action="description.php" method="post" id="item">
<div class="product">
<div class="product-thumb" name = "image" id ="image">
<?php echo '<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>' ?>
<input type="hidden" name='product_image' id="product_image"
value="<?php echo '<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>' ?>" />
//input closing tag is clashed with img to closing tag
</div>
<div class="overlay">
<button name="add_to_cart" type="submit" class="btn btn-lg btn-dark btn-theme-colored btn btn-circled text-uppercase font-weight-5" href="shop-cart.html" >Add To Cart</button>
</div>
</div>
</div>
</form>
</div>
<?php
}
}
?>
解决方案
我认为您将图像发送到浏览器然后将其发送回服务器的方式是一个坏主意。我不能告诉你正确的方法,因为我不知道你在做什么的上下文。
但是,您的问题的解决方案是img
使用如下函数转义标签中的字符htmlentities
:
<input
type="hidden"
name='product_image'
id="product_image"
value="<?php echo htmlentities('<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>'); ?>" />
推荐阅读
- python - 修订 - 如何从 pandas 中检索数据
- jersey - 带有 Google Guice 4.2.3 的 Jersey 2.34 中的 DI 示例
- python - 自变量是否需要单独进行特征缩放?
- python - 如果满足某个条件,如何增加熊猫的列?
- terragrunt - 删除从 Terragrunt remote_state 制作的资源?
- python - Qt BarModelMapper 中的千位分隔符
- kubernetes - 多容器 pod 中的连接被拒绝
- css - 使用 SVG 进行星级评定
- macos - 防止导出 LDFLAGS 和 CPPFLAGS
- php - CodeIgniter 4 与多个子域共享 BaseController