dongyinting3179
2016-08-10 10:28
浏览 54
已采纳

我的JavaScript脚本不会在php中回显

i have a ads script which i stored in my database using textarea field. but when i echo that script in php. then it will not working. this is my script which i saved in database by using textarea field.

<script type="text/javascript">
  ( function() {
  if (window.CHITIKA === undefined) { window.CHITIKA = { 'units' : [] }; };
  var unit = {"calltype":"async[2]","publisher":"seeknfameads","width":300,"height":250,"sid":"Chitika Default","color_site_link":"337ab7","color_text":"337ab7"};
  var placement_id = window.CHITIKA.units.length;
  window.CHITIKA.units.push(unit);
  document.write('<div id="chitikaAdBlock-' + placement_id + '"></div>');
  }());
</script>
<script type="text/javascript" src="//cdn.chitika.net/getads.js" async></script>

And when i fetch field and try to echo this. it is not working.

  $sql4 = "SELECT * FROM abc ORDER BY id DESC LIMIT 1";
            $query4 = $conn->query($sql4);
            $row4 = $query4->fetch(PDO::FETCH_ASSOC);
            $video_des=$row4['video_des'];
            $rowc = $query4->rowCount(PDO::FETCH_ASSOC);
            if ($rowc>=1){
            <script><?php echo $video_des;?></script>
            }

please help to fix this problem.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • duanqiang7631 2016-08-10 10:43
    最佳回答

    As you are already inserting value of video_des with <script> and </script> tag

    You don't need to add <script> tag again, Please try below.

     $sql4 = "SELECT * FROM abc ORDER BY id DESC LIMIT 1";
            $query4 = $conn->query($sql4);
            $row4 = $query4->fetch(PDO::FETCH_ASSOC);
            $video_des=$row4['video_des'];
            $rowc = $query4->rowCount(PDO::FETCH_ASSOC);
            if ($rowc>=1){
              echo $video_des;
            }
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题