Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am completely stumped on this one. COMPLETELY stumped.

I'm building the framework for an ad network. While prototyping, I did most my building at Kodingen. Everything worked fine over there. I just migrated to a new host, though, and I've got this one weird problem. Weird.

Bear with me as I explain this.

The ads for my ad network are placed through a code snippet that the user places on his site. Here's the code snippet:

<script type="text/javascript">
document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333"></scr' + 'ipt>');
  </script>

And, after PHP processes the request, here's the output on the ad_engine.php page:

document.write("<div class='adframe' style='min-width:250px; min-height:100px;'><a href='click.php?adid=4224&pid=333' target='_self''><img src='http://mysite.net/ads/image.png' border='0' class='adimage' style='min-width:125px; min-height:100px;' /></a><span class='adtext'><a href='click.php?adid=4224&pid=333' target='_self''>This is the ad contents right here</a></span></div>");

This method worked fine when I was developing on Kodingen. The ad appeared on any page I placed this snippet on. But, since having migrated to my new server - and not having changed anything - this method won't work.

ON THE NEW SERVER: ad_engine.php, when typed directly into the address bar, shows the ad like usual. But when it's loaded onto any other page via that first code snippet I showed you, the ad won't appear. Strangely enough, the OLD ad_engine.php file - the one on my old host - still works fine even if I load it onto a page on my new host. Follow?

Although no ad appears, I know that the ad_engine.php page, the one on my new host, I know that it IS being processed, because MySQL changes are made like they're supposed to.

I've tried to be as clear as I can in explaining this problem, if you've got any questions just let me know.

Help?

share|improve this question
    
Stabbing in the dark here, but are you relying on settings in the PHP ini that might have changed? register_globals could be switched off now, for instance? It would probably be pretty helpful if you put an actual URL of the JS file on your server for people to test with. –  Grim... Jan 28 '12 at 1:17
    
Please add some of your PHP source code for debugging, although I reckon there is a pretty good chance that PHP errors are breaking your Javascript on the new server. Try adding ini_set('display_errors',0); at the very top of ad_engine.php. You need to look at the raw output of ad_engine.php (as do we). And that looks like a slightly odd way of adding a new script to the DOM - for one thing, document.write makes me shudder... –  DaveRandom Jan 28 '12 at 1:23
1  
This is a long shot but do you have adblock installed by any chance? It blocks/hides divs with a class of "adframe". –  pjumble Jan 28 '12 at 1:26
    
Sounds like a MIME type issue. Did the original server have a STRUTS layer (or similar) to make a special case of that particular .php file - eg. to serve it with an application/javascript header? –  Beetroot-Beetroot Jan 28 '12 at 2:07
    
ahh okay. the ad_engine page is at blueprintads.net/ad_engine.php –  user1152706 Jan 28 '12 at 6:18

1 Answer 1

Already tested a caching problem? Maybe your new host has different cache settings?

Try adding some random number to the .php call:

document.write('<scr' + 'ipt type="text/javascript" src="http://mysite.net/ad_engine.php?pid=333&x=RANDOM_NUMBER_GOES_HERE"></scr' + 'ipt>');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.