0

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.

3
  • did you save your script with the <script> tag or without <script> tag? Commented Aug 10, 2016 at 10:42
  • then why you are echoing your script in <script> tag Commented Aug 10, 2016 at 10:46
  • i got this point buddy. thanks without <script> now it is working. Commented Aug 10, 2016 at 10:49

2 Answers 2

1

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;
        }
Sign up to request clarification or add additional context in comments.

Comments

1

Simply do this at your if condition result

if ($rowc>=1){
         echo $video_des; // remove script tag from here
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.