gaspower Posted October 20, 2012 Posted October 20, 2012 Hello I am trying to add Paypal Bill Me Later banner code to a box I created, but when I add the script code, it breaks the site. Current Working Code: function dataF() { $data = '<div class="img"><img src="/images/dealers-175.gif"></div>'; return $data; } function execute() { global $oscTemplate; $oscTemplate->addBlock($this->dataF(), $this->group); } Changed To: function dataF() { $data = '<div><script type="text/javascript">document.write('<scr');document.write('ipt type="text/javascript" data-ppmnid="43423" src="//ad.where.com/jin/spotlight/ads?pubid=05693f&format=js&v=2.4&placementtype=120x240&ppmnid=43423&rand=' + Math.round(Math.random() * 100000000000000) + '">');document.write('</scr' + 'ipt>');</script></div>'; return $data; } function execute() { global $oscTemplate; $oscTemplate->addBlock($this->dataF(), $this->group); } Thanks JR
multimixer Posted October 20, 2012 Posted October 20, 2012 You need to escape any quotes you have within the <script></script> tags My community profile | Template system for osCommerce - New: Responsive | Feedback channel
gaspower Posted October 20, 2012 Author Posted October 20, 2012 Hello Multimixer, First wanted to say I use your template system and it is great.. Thank you. I removed all the quotes, and I still get the same error, crashes page. Thanks JR
gaspower Posted October 20, 2012 Author Posted October 20, 2012 Sorry, I think I misunderstood meaning of "escape". You mean to use "/". Is there a link you can send me to understand the escape process? JR
Chris H Posted October 22, 2012 Posted October 22, 2012 Like multimixer says. The escape character is the back-slash, not the forward-slash. Your $data string is within single-quotes. But the string itself contains single-quotes, and this is confusing php. So each of them, that is within the string, must be preceded by a back-slash .'<div><script type="text/javascript">document.write(\'<scr\');document.write(\'ipt type="text/javascript" data-ppmnid="43423" src="//ad.where.com/jin/spotlight/ads?pubid=05693f&format=js&v=2.4&placementtype=120x240&ppmnid=43423&rand=\' + Math.round(Math.random() * 100000000000000) + \'">\');document.write(\'</scr\' + \'ipt>\');</script></div>'
Recommended Posts
Archived
This topic is now archived and is closed to further replies.