Ads In Php Not Working

Started on the old forum in July 2007 · view the original in the archive · old links redirect here

9 replies · 1,017 views · started 19 years ago · 1 min read

3 participants
doktorg #1

Hi All,

I am new to this mobile stuff.

Been searching forums and making phone calls to try to figure out why the direct link php ad script is not being interpreted in my sites.

The sites are http://sergeantbrettscoffee.mobi and http://mobisize.mobi They are hosted on GoDaddy in a shared hosting account. I have used several php mail scripts in my other sites in the same account with no problem.

Even a simple echo wont't work.

I've tried putting a .htaccess file in the folder with AddType application/x-httpd-php .htm .html .php and variants, including one with .wml and also with the file extensions without the dots. I keep getting parse errors.

Please help.

Regards, doktorg

amylee Principal · 1,092 posts #2

what ad service are you using?

doktorg #3

what ad service are you using?

We are using admob.

amylee Principal · 1,092 posts #4
echo '<p align="center">[size="1"]';
     /* editable area */
  $mob_mode = 'live'; // change mode from "test" to "live" when you are done testing
  $mob_alternate_link = '[url]http://lavalair.net';[/url] // use this to set a default link to appear if AdMob does not return an ad.
    
  /* end editable area */
    
  //used for ad targeting
  $mob_contents = '';
  $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
  $mob_ip = urlencode($_SERVER['REMOTE_ADDR']);
  
  if ($mob_mode=='test')
      $mob_m = "&m";

  $mob_url = '[url]http://ads.admob.com/ad_source.php?s=SITE[/url] ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m;

  @$mob_ad_serve = fopen($mob_url,'r');
    
  if ($mob_ad_serve) {
      while (!feof($mob_ad_serve))
          $mob_contents .= fread($mob_ad_serve,1024);
      fclose($mob_ad_serve);
  }
  $mob_link = explode("><",$mob_contents);

  $mob_ad_text = $mob_link[0];
  $mob_ad_link = $mob_link[1];

  if (isset($mob_ad_link) && ($mob_ad_link !='')) {
      //display AdMob Ad
      echo '[url="'. $mob_ad_link .'"]'. $mob_ad_text . '[/url]';
  }
  else {
      //no AdMob ad, display alternate
      echo $mob_alternate_link;
  }
 echo '[/size]</p>';
    $ret = "\n</card>\n</wml>";
    return $ret;
}
function xhtml_footer()
{    
    echo '<h3 align="center">[size="1"]';
     /* editable area */
  $mob_mode = 'live'; // change mode from "test" to "live" when you are done testing
  $mob_alternate_link = '[url]http://lavalair.net';[/url] // use this to set a default link to appear if AdMob does not return an ad.
    
  /* end editable area */
    
  //used for ad targeting
  $mob_contents = '';
  $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
  $mob_ip = urlencode($_SERVER['REMOTE_ADDR']);
  
  if ($mob_mode=='test')
      $mob_m = "&m";

  $mob_url = '[url]http://ads.admob.com/ad_source.php?s=SITE[/url] ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m;

  @$mob_ad_serve = fopen($mob_url,'r');
    
  if ($mob_ad_serve) {
      while (!feof($mob_ad_serve))
          $mob_contents .= fread($mob_ad_serve,1024);
      fclose($mob_ad_serve);
  }
  $mob_link = explode("><",$mob_contents);

  $mob_ad_text = $mob_link[0];
  $mob_ad_link = $mob_link[1];

  if (isset($mob_ad_link) && ($mob_ad_link !='')) {
      //display AdMob Ad
      echo '[url="'. $mob_ad_link .'"]'. $mob_ad_text . '[/url]';
  }
  else {
      //no AdMob ad, display alternate
      echo $mob_alternate_link;
  }
 echo '[/size]</h3>';
    $ret = "\n</body>\n</html>";
    return $ret;
}
function xhtml_header($page_title, $page_style="")
{

thats my admob code think its the same just make sure its right on your scripts, also you have your correct site id in the $mob_url = 'http://ads.admob.com/ad_source.php?s=SITE ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m; bits and also that your ads are in live mode and not test

amylee Principal · 1,092 posts #5
echo '<p align="center">[size="1"]';
     /* editable area */
  $mob_mode = 'live'; // change mode from "test" to "live" when you are done testing
  $mob_alternate_link = '[url]http://lavalair.net';[/url] // use this to set a default link to appear if AdMob does not return an ad.
    
  /* end editable area */
    
  //used for ad targeting
  $mob_contents = '';
  $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
  $mob_ip = urlencode($_SERVER['REMOTE_ADDR']);
  
  if ($mob_mode=='test')
      $mob_m = "&m";

  $mob_url = '[url]http://ads.admob.com/ad_source.php?s=SITE[/url] ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m;

  @$mob_ad_serve = fopen($mob_url,'r');
    
  if ($mob_ad_serve) {
      while (!feof($mob_ad_serve))
          $mob_contents .= fread($mob_ad_serve,1024);
      fclose($mob_ad_serve);
  }
  $mob_link = explode("><",$mob_contents);

  $mob_ad_text = $mob_link[0];
  $mob_ad_link = $mob_link[1];

  if (isset($mob_ad_link) && ($mob_ad_link !='')) {
      //display AdMob Ad
      echo '[url="'. $mob_ad_link .'"]'. $mob_ad_text . '[/url]';
  }
  else {
      //no AdMob ad, display alternate
      echo $mob_alternate_link;
  }
 echo '[/size]</p>';
    $ret = "\n</card>\n</wml>";
    return $ret;
}
function xhtml_footer()
{    
    echo '<h3 align="center">[size="1"]';
     /* editable area */
  $mob_mode = 'live'; // change mode from "test" to "live" when you are done testing
  $mob_alternate_link = '[url]http://lavalair.net';[/url] // use this to set a default link to appear if AdMob does not return an ad.
    
  /* end editable area */
    
  //used for ad targeting
  $mob_contents = '';
  $mob_ua = urlencode(getenv("HTTP_USER_AGENT"));
  $mob_ip = urlencode($_SERVER['REMOTE_ADDR']);
  
  if ($mob_mode=='test')
      $mob_m = "&m";

  $mob_url = '[url]http://ads.admob.com/ad_source.php?s=SITE[/url] ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m;

  @$mob_ad_serve = fopen($mob_url,'r');
    
  if ($mob_ad_serve) {
      while (!feof($mob_ad_serve))
          $mob_contents .= fread($mob_ad_serve,1024);
      fclose($mob_ad_serve);
  }
  $mob_link = explode("><",$mob_contents);

  $mob_ad_text = $mob_link[0];
  $mob_ad_link = $mob_link[1];

  if (isset($mob_ad_link) && ($mob_ad_link !='')) {
      //display AdMob Ad
      echo '[url="'. $mob_ad_link .'"]'. $mob_ad_text . '[/url]';
  }
  else {
      //no AdMob ad, display alternate
      echo $mob_alternate_link;
  }
 echo '[/size]</h3>';
    $ret = "\n</body>\n</html>";
    return $ret;
}
function xhtml_header($page_title, $page_style="")
{

thats my admob code think its the same just make sure its right on your scripts, also you have your correct site id in the $mob_url = 'http://ads.admob.com/ad_source.php?s=SITE ID HERE&u='.$mob_ua.'&i='.$mob_ip.$mob_m; bits and also that your ads are in live mode and not test

doktorg #6

amylee,

Many thanks. When I saw the echo at the top of your script, it led me in the right direction. I converted all the pages into php, did some cleaning up, and voila, it all worked.

External image (may be gone) doctorg

rukiya Lead · 569 posts #9

do we have to edit the admob add code somewhere? i have noticed that time to time my site gives errors. i used the admob php curl code and made a php file in included in on my page is there something wrong? External image (may be gone)

time to time your site gives errors,because you mess up the codes,files etc. change $mob_mode = 'live'; add here your SITE ID $mob_url = 'http://ads.admob.com/ad_source.php?s=SITE ID include the .php file like include("ad.php"); and to test if you admob account get live ads,check by using the echo" <a href="...........</a>; link

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close