Help with php

Discussion in 'HTML & Website Design' started by billywizz, Mar 28, 2013.

  1. #1
    Im trying to put adds on my site with a php include ,but it's not having it
    could somebody tell me whats wrong I have been trying for hours.
    Thanks
    --------------------------------------------------------------------------------------


    <link href="css/auto.css" rel="stylesheet" type="text/css">
    <meta name="viewport" content="width=device-width, height=device-height, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    </head>
    <body>
    <div id="wrapper">
    <div id="header-logo"><span class="header-text">
    <h1>Tips to Avoid Disappointment </h1>
    </span> </div>

    <br><center>
    <p>
    <center>

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

    <br><center>

    <p>
    <center>
     
    billywizz, Mar 28, 2013 IP
  2. creativewebmaster

    creativewebmaster Active Member

    Messages:
    654
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    78
    #2
    This is correct code: <?php include 'menu.php'; ?>
     
    creativewebmaster, Mar 28, 2013 IP
  3. billywizz

    billywizz Well-Known Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #3
    Hi thanks for the reply ,its still not working ,I have this in my ad.php file is this correct?


    <?php

    <script type="text/javascript"><!--
    google_ad_client = "xxxxxxxxxxxxxxxxxxx";
    /* app */
    google_ad_slot = "xxxxxxxxxxxxxxxxxxxxxx";
    google_ad_width = 300;
    google_ad_height = 250;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';
    ?>
     
    billywizz, Mar 28, 2013 IP
  4. navynav17

    navynav17 Member

    Messages:
    12
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #4
    use like this <?php include("ad.php"); ?> and be sure ad.php and the file where you are placing this code are on same folder.
     
    navynav17, Mar 28, 2013 IP
  5. billywizz

    billywizz Well-Known Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #5
    thanks guys is my ad.php code correct ? or is it just the adsense code without the <?php etc
     
    billywizz, Mar 28, 2013 IP
  6. Lewis Young

    Lewis Young Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #6
    Remove the PHP tags from your ad.php file so its just the adsense code inside the script tags. Then include the file with:

    <?php include("ad.php"); ?>
    Code (markup):
    Thats assuming the ad.php is in the same directory as the page you want the ads to display on.
     
    Lewis Young, Mar 28, 2013 IP
  7. billywizz

    billywizz Well-Known Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #7
    still no good ...latestiphone.mobi/test-site/1.html
    latestiphone.mobi/ad.php
     
    billywizz, Mar 28, 2013 IP
  8. Lewis Young

    Lewis Young Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #8
    Rename 1.html to 1.php

    Or add this line to your .htaccess

    AddType application/x-httpd-php .html
    Code (markup):
     
    Last edited: Mar 28, 2013
    Lewis Young, Mar 28, 2013 IP
  9. billywizz

    billywizz Well-Known Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #9
    That got it thanks so much
     
    billywizz, Mar 28, 2013 IP
  10. Lewis Young

    Lewis Young Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #10
    No worries. For the record, you cant run php directly from a .html extension.
     
    Lewis Young, Mar 28, 2013 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #11
    No, it isn't... do we SEE a problem here?

    <?php
     
    <script type="text/javascript"><!--
    Code (markup):
    You put markup and scripting inside PHP tags. Javascript and markup doesn't go there! Lose the <?php at the start and ?> at the end, and the file will be sent client side. What you're doing now is trying to run client side javascript as server-side PHP... which is likely throwing some sort of PHP error I'd hope.

    I'm a little surprised nobody else noticed this -- but again it's another of the reasons I'm in favor of having <?php ?> stricken from PHP entirely.

    NOT that the markup isn't bad either width the DIV and span around the H1 likely for no good reason, and the presence fo the CENTER tag that has no business in any HTML written after 1998. Much less opening it more than once without closing it which makes even less sense...

    -- edit --
    oops, my bad, t0asty noticed it, but didn't elaborate very well... Guess my TSDR kicked in again. (too short, didn't read)
     
    deathshadow, Mar 28, 2013 IP