Hello! I am trying to put adsense code inside php page but i always receive "Unexpected t_string" error message. Let assume my adsense is this: <script type="text/javascript"><!-- google_ad_client = "pub-000000000000000"; /* 468x15, created 5/14/10 */ google_ad_slot = "0000000000"; google_ad_width = 468; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> What should i put before and at the end of the adsense code to make it work? Thank you for any help
It's because your using the echo statement to output the code. All those quotes in the javascript code are messing up the echo function. Try escaping all the quotes in the google code (" become \").
<? $adsense = ' <script type="text/javascript"><!-- google_ad_client = "pub-000000000000000"; /* 468x15, created 5/14/10 */ google_ad_slot = "0000000000"; google_ad_width = 468; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> '; echo $adsense; ?> PHP:
No it isn't, most webmasters do it because most websites run on PHP or some CMS and you have to modify the JS code so that it can be spat out by the programming language. The only way to violate Google's TOS is to a) conceal parts of the adsense block, or b) click ads on your own site.
The only thing that matters with Google Adsense TOS, is that the finished output (source code) doesn't change. Verify, by looking at your webpage sourcecode in your browser...
Another one is save the code in a html file say adsense.html and now call it using include This is so simple. You can modify adsense.html at any time to update all the files that contain it!