php htmlentities($str)与jQuery?

php htmlentities($str)与jQuery?,php,jquery,mysql,html,Php,Jquery,Mysql,Html,我通过htmlentities($str)重复引用,它第一次起作用,但它用于图像上的标题,单击时通过jQuery进行交换-然后标题显示html实体“ 我如何用引号回应文本,使其仍然显示为“而不是$quot”;点击后 这是我的html <div class="smallImageWrapper"> <?php if(empty($row_rsPTN['img1'])): echo "" ?> <?php else: ?> &l

我通过htmlentities($str)重复引用,它第一次起作用,但它用于图像上的标题,单击时通过jQuery进行交换-然后标题显示html实体

我如何用引号回应文本,使其仍然显示为“而不是$quot”;点击后

这是我的html

<div class="smallImageWrapper">
      <?php if(empty($row_rsPTN['img1'])): echo "" ?>
      <?php else: ?>
      <span class="smallImage"><img src="../images/products/pbetn/50x50/<?php echo $row_rsPTN['img1']; ?>" alt="<?php echo htmlentities($row_rsPTN['img1caption']); ?>" name="smallImage" id="smallImage1" height="50px" width="50px" /></span>
      <?php endif; ?>

“alt=”“name=“smallImage”id=“smallImage1”height=“50px”width=“50px”/
下面是我交换图像的jQuery:

$("#smallImage1").bind("click", function() {
  $("#largeimage").attr("src","../images/products/pbetn/180x280/<?php echo $row_rsPTN['img1']; ?>");
  $("#largeimage").attr("alt","<?php echo htmlentities($row_rsPTN['img1caption']); ?>");
  $(".caption").text("<?php echo htmlentities($row_rsPTN['img1caption']); ?>");
});
$(“#smallImage1”).bind(“单击”,函数(){
$(“#largeimage”).attr(“src”,”./images/products/pbetn/180x280/”;
$(“#大图像”).attr(“alt”,“alt”);
$(“.caption”).text(“”);
});
这里有一个指向我的测试站点的链接,您可以在其中看到它的发生:

如果你需要更多信息,请告诉我。 谢谢!

更改此行:

$("#largeimage").attr("alt","<?php echo htmlentities($row_rsPTN['img1caption']); ?>");
$(“#大图像”).attr(“alt”,“alt”);
为此:

$("#largeimage").attr("alt","<?php echo addslashes($row_rsPTN['img1caption']); ?>");
$(“#大图像”).attr(“alt”,“alt”);

jQuery自动对事物进行实体化,因此您不需要在该引号中添加实体。您只需要转义任何引号。因此,
addslashes

好的,现在我有一个错误:“PHP致命错误:调用D:\websites\public\u html\new\test\products\ptn.PHP第197行中未定义的函数addslahses()”是一个打字错误。已修复。(应该是“addslashes”,而不是“addslashes”)。太棒了!对不起,我应该抓到的。我一整天都在为这个挠头。非常感谢!