Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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中不能正确显示_Php_Html - Fatal编程技术网

从数据库接收的值不是';在php中不能正确显示

从数据库接收的值不是';在php中不能正确显示,php,html,Php,Html,大家好,请帮助我,我有一个php代码,我从数据库中获取数据并显示在web上,如果您检查下面的输入隐藏标记,我给了它一个值,但不是所有的值都正确显示在其中。而是创建一个属性 PHP代码 <?php $output = ''; $sqlNO = "SELECT * FROM pnewoffer"; $NOresult = mysqli_query($conn, $sqlNO); if(mysqli_num_rows($NOresult) > 0) {

大家好,请帮助我,我有一个php代码,我从数据库中获取数据并显示在web上,如果您检查下面的输入隐藏标记,我给了它一个值,但不是所有的值都正确显示在其中。而是创建一个属性

PHP代码

<?php
   $output = '';
    $sqlNO = "SELECT * FROM pnewoffer";

     $NOresult = mysqli_query($conn, $sqlNO);
     if(mysqli_num_rows($NOresult) > 0) {
         while($row = mysqli_fetch_array($NOresult)) {
         $output .= '<div class="offer-card">
          <form action="./bked/savedit.php" method="post">
            <a href="#" class="offer-card-inner">
            <div class="offer-img">
              <img src="./image/'.$row['offerPImage'].'" alt="New Offer Image" width="200">
            </div>
          <div class="offer-info">
               <h3 class="offer-title">'.$row['offerPName'].'</h3>
                  <div class="clearfix rating marT8 ">
                     <div class="rating-stars ">
                        <div class="grey-stars"></div>
                         <div class="filled-stars" style="width:60.0%"></div>
                      </div>
                   </div>
                   <h4 class="offer-product-price">N'.$row['offerPPrice'].' </h4>
          </div>
       </a>
                    <input type="hidden" name="newPPrice" value='.$row['offerPPrice'].'>
                    <input type="hidden" name="newPName" value='.$row['offerPName'].'>
                    <input type="hidden" name="newPImg" value='.$row['offerPImage'].'>

       <div class="offer-bt-btn">
          <div class="offer-btn">
             <button type="submit" name="saveForLater" class="favorite-offer-btn">
                <i class="far fa-heart"></i>
             </button>
              <a href="#" class="offer-product-info-btn">
               <i class="fa fa-info"></i>
               </a>
           </div>
       </div>

     </form>
   </div>';
   }
  }

  echo $output;

?>


结果

<input type="hidden" name="newPName" value="Blue" louis="" vuitton="" women="" bag="">
<input type="hidden" name="newPName" value="Samsung" galaxy="" s9="" 6gb="" ram,="" 32gb="" rom,="" 16mpbs="">

实际上应该是

<input type="hidden" name="newPName" value="Samsung Galaxy S9 6gb ram, 32gb rom, 16mpbs">
<input type="hidden" name="newPName" value="Blue Louis Vuitton Women Bag">


请问,我该怎么做?

如果任何值包含
字符,则将结束
属性并启动一个新属性。使用
htmlspecialchars()
对其进行编码并防止出现这种情况

<input type="hidden" name="newPPrice" value='.htmlspecialchars($row['offerPPrice'], ENT_QUOTES).'>
<input type="hidden" name="newPName" value='.htmlspecialchars($row['offerPName'], ENT_QUOTES).'>
<input type="hidden" name="newPImg" value='.htmlspecialchars($row['offerPImage'], ENT_QUOTES).'>


为什么会有重复的名称属性?@FunkFortyNiner我忘了删除它,但我的代码中不是这样的,这只是一个示例请尝试对问题的值属性状态使用额外的双QOUTING?