homepage Welcome to WebmasterWorld Guest from 54.163.139.36
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

    
adsense in php code
dont know why its happening!
StuntasticAudi

5+ Year Member



 
Msg#: 12208 posted 10:27 pm on Feb 19, 2006 (gmt 0)

I'm creating a new site..and i was designing the layout of the site and where to put the ads and stuff when i ran into a lil problem. When I put the adsense code into one of my tables and then refresh the page to see how it looks, it makes the page blank, nothing shows up. if i put regular text in that table it shows up with the text but as soon as i put the adsense script the page loads as a blank...why?

 

joftech

5+ Year Member



 
Msg#: 12208 posted 3:45 am on Feb 20, 2006 (gmt 0)

I used to experience this too. Maybe adsense does not like (<? php) syntax.

I will appreciate any workaround this.

Jafo

5+ Year Member



 
Msg#: 12208 posted 3:49 am on Feb 20, 2006 (gmt 0)

Does your script have error_reporting turned off? Sounds like you are getting an error and the script is dying but not returning any reason why.

I use Adsense in PHP all the time.

jema

10+ Year Member



 
Msg#: 12208 posted 1:36 pm on Feb 20, 2006 (gmt 0)

Same here, so just assume you have made a silly mistake!

wonderboy

10+ Year Member



 
Msg#: 12208 posted 2:15 pm on Feb 20, 2006 (gmt 0)

Try putting your ad code in 'ad.php' and then including it in your main page.

<?PHP include "ad.php";?>

That's if you aren't already doing something like this of course. This method is also a lot more dynamic than simply pasting your code on every single page of the site.

W.

Jafo

5+ Year Member



 
Msg#: 12208 posted 2:52 pm on Feb 20, 2006 (gmt 0)

Try putting your ad code in 'ad.php' and then including it in your main page.

This is the best way to do it for sure. When a time comes when you want to change the layout of the ad, you only have to edit one file instead of multiple ones.

Taran

10+ Year Member



 
Msg#: 12208 posted 4:13 pm on Feb 20, 2006 (gmt 0)

Hi,

This page appears blank when there error in php code.

If you are using it like <?php

echo"

<script type="text/javascript"><!--
google_ad_client = "#*$!";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "E7C794";
google_color_bg = "E7C794";
google_color_link = "000000";
google_color_url = "FFFFFF";
google_color_text = "993300";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

";

put in "\" back slash everywhere in php code.

dont put back slashes for echo tags.

wrong way

<?php

echo "

<script type="text/javascript"><!--

";
?>

correct way

<?php

echo "

<script type=\"text/javascript\"><!--

";
?>

just notice the back slashes.

StuntasticAudi

5+ Year Member



 
Msg#: 12208 posted 4:15 pm on Feb 20, 2006 (gmt 0)

thanks taran..that worked!

Taran

10+ Year Member



 
Msg#: 12208 posted 4:35 pm on Feb 20, 2006 (gmt 0)

you are welcome.

actually the same thing happened to me few years ago when I moved from html to php.

there's lots more to learn for you.

Jafo

5+ Year Member



 
Msg#: 12208 posted 4:47 pm on Feb 20, 2006 (gmt 0)

Honestly, it is just easier to do this:


some php code here;
?>
PUT ADSENSE CODE HERE
<?php
Resume php code here;

end;
?>

The nice thing about PHP is that you can include HTML and code on the same page, just close the <?php tag, enter your HTML, and then open it back up. You can do this inside of a loop, while, foreach, if, etc., blocks. For example:


<?php
foreach ($items as $item) {
?>

I have an item, and it's name is <?php echo $item;?>

<?php
}
?>

StuntasticAudi

5+ Year Member



 
Msg#: 12208 posted 9:57 pm on Feb 20, 2006 (gmt 0)

Taran,
Instead of putting \ in all of my codes can i just do it in the adsense code. it seems it's easier...would that be considered messing with the code and is that against the TOS.

caspita

10+ Year Member



 
Msg#: 12208 posted 10:02 pm on Feb 20, 2006 (gmt 0)

Intead of puting \ before every double-quote ". Just start and en your php string using single quotes. Like:

$string = 'this displays a double quote here " and again here ". now, I am closing the string';

insted of :

$string = "this displays a double quote here \" and again here \". now, I am closing the string";

Both of them work, but the first one was opened-closed using single quote, so, no need to put \ before the double quotes.

MyGen

5+ Year Member



 
Msg#: 12208 posted 10:05 pm on Feb 20, 2006 (gmt 0)

Easier still is:

echo <<<END
put anything you like here, dont need to escape any """" invalid characters or the like.
END;

Or if you are just including a file, dont have to worry about escaping any of the chars, just use

include_once('your_ad_file.ext');

Taran

10+ Year Member



 
Msg#: 12208 posted 3:13 pm on Feb 21, 2006 (gmt 0)

Taran,
Instead of putting \ in all of my codes can i just do it in the adsense code. it seems it's easier...would that be considered messing with the code and is that against the TOS.

..

No the actual output of the echo command will not include back slashes.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved