Php 转义符字符

Php 转义符字符,php,ajax,escaping,htmlspecialchars,Php,Ajax,Escaping,Htmlspecialchars,我使用Ajax从数据库中检索一个字符串,该字符串有一个符号和字符“&”,如:“双核2.15GHz Kryo和双核1.44GHz Kryo” 我将文本显示在输入字段中,并且可以正确地看到它。 然后,我尝试用POST方法将它发送到另一个页面,在这里我得到“403错误” 我知道是符号和字符,因为我在双引号中遇到了同样的问题,我这样解决了这个问题: htmlentities(stripslashes(utf8_decode($display))) 但我不知道如何逃离这个符号。。。 我在这里查看了其他张

我使用Ajax从数据库中检索一个字符串,该字符串有一个符号和字符“&”,如:“双核2.15GHz Kryo和双核1.44GHz Kryo”

我将文本显示在输入字段中,并且可以正确地看到它。 然后,我尝试用POST方法将它发送到另一个页面,在这里我得到“403错误”

我知道是符号和字符,因为我在双引号中遇到了同样的问题,我这样解决了这个问题:

htmlentities(stripslashes(utf8_decode($display)))
但我不知道如何逃离这个符号。。。 我在这里查看了其他张贴的问题,但似乎没有任何效果

请帮忙

该解决方案被张贴为类似的不适用于我

我将为您提供更多代码:

<?php
for($i=1; $i <= 9; $i++){
${'content' . $i}='<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">

$(function(){
$("#searchid'.$i.'").keyup(function() 
{ 
var searchid'.$i.' = $(this).val();
var dataString = \'search=\'+ searchid'.$i.';
if(searchid'.$i.'!=\'\')
{
    $.ajax({
    type: "POST",
    url: "searchspecs.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
    $("#result'.$i.'").html(html).show();

    $(".name").click(function(){
    document.getElementById("brand'.$i.'").value = $(this).nextAll().eq(7).text();
    document.getElementById("model'.$i.'").value = $(this).nextAll().eq(6).text();
    document.getElementById("id'.$i.'").value = $(this).nextAll().eq(0).text();
    document.getElementById("storage'.$i.'").value = $(this).nextAll().eq(1).text();    
    document.getElementById("cpu'.$i.'").value = $(this).nextAll().eq(2).text();
还有一个问题。。。如果文本中有“或”,我也会收到403禁止的错误,例如:“16 GB、32 GB或64 GB”

可能重复的
htmlentities(stripslashes(utf8_decode($display)))
<?php
for($i=1; $i <= 9; $i++){
${'content' . $i}='<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">

$(function(){
$("#searchid'.$i.'").keyup(function() 
{ 
var searchid'.$i.' = $(this).val();
var dataString = \'search=\'+ searchid'.$i.';
if(searchid'.$i.'!=\'\')
{
    $.ajax({
    type: "POST",
    url: "searchspecs.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
    $("#result'.$i.'").html(html).show();

    $(".name").click(function(){
    document.getElementById("brand'.$i.'").value = $(this).nextAll().eq(7).text();
    document.getElementById("model'.$i.'").value = $(this).nextAll().eq(6).text();
    document.getElementById("id'.$i.'").value = $(this).nextAll().eq(0).text();
    document.getElementById("storage'.$i.'").value = $(this).nextAll().eq(1).text();    
    document.getElementById("cpu'.$i.'").value = $(this).nextAll().eq(2).text();
$cpu=$_POST['cpu'.$p];