Having trouble with replace code

Discussion in 'PHP' started by scottlpool2003, Feb 11, 2009.

  1. #1
    Hi guys, having a little trouble replacing keywords and descriptions...

    Layout.php
    	echo "<meta name='keywords' content='".$keywords."' />";
    	echo "<meta name='description' content='".$description."' />";  
    PHP:
    Replace page
    <?
    $title = 'My title tag for this page';
    $keywords = 'my keywords';
    $description = 'my description';
    
    ?>
    PHP:
    When I view the source code I get
    <meta name='keywords' content='' /><meta name='description' content='' />
    PHP:
    I really can't work out why it doesn't work so if someone could help I will be really grateful. I didn't notice until the site got indexed in Google, disaster! Lol well at least I spotted it relatively soon!
     
    scottlpool2003, Feb 11, 2009 IP
  2. tihan

    tihan Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    Maybe "$keywords = 'my keywords';" is AFTER the meta tags?
     
    tihan, Feb 11, 2009 IP
  3. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #3
    Thanks tihan but I'm including a layout file, and I need to have different titles and keywords for each page. I'll try using an if statement instead maybe something like:

    function ShowHeader($Title,$MetaDesc){$DefTitle = "Show me when title is blank";$DefMetaDesc = "Show me when Meta Desc is blank";if($Title=="")$Title=$DefTitle;if($MetaDesc=="")$MetaDesc=$DefMetaDesc;//header stuff goes here}
    PHP:
     
    scottlpool2003, Feb 11, 2009 IP