PHP and Meta Tag Issues

Discussion in 'PHP' started by LazyD, Jan 1, 2007.

  1. #1
    I am having an issue with PHP and Meta Tags on my website. For the longest time I have wondered why my site is not getting indexed, I ran a quick Meta Tag Analyzer and it turns out that the Meta Tags for my pages werent being read at all.

    It looks like the culprit is PHP on the page above the Meta Tags, once I remove the PHP code the Meta Tags work fine.

    The problem with that is that on many of my pages I use a $_GET to get a Category and SubCat from the URL which then goes through a SWITCH statement that defines the meta information like title, keywords, description etc. So, if I cant put that PHP info above my meta tags im stuck with putting them below, which is an issue because the the variables are then blank because they havent been set yet.

    What can I do to resolve this problem?
     
    LazyD, Jan 1, 2007 IP
  2. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Posting your code would really help. Making some big assumptions:
    
    <?php
    cat=$_GET['cat'];
    subcat=$_GET['subcat'];
    
    switch ($cat) {
    case "tools":
       echo "<title>Tools</title>";
       break;
    case "books":
       echo "<title>Books</title>";
       break;
    default:
       echo "<title>Unknown Category</title>";
       break;
    };
    ?>
    PHP:
     
    tandac, Jan 1, 2007 IP
  3. INTEMPO

    INTEMPO Active Member

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #3
    May be you PHP script didn't allow out of Metas. It might be if your Metas were located in some IF statement.

    As another reason php might make printing some invalid HTML before Metas were printed.

    Ex:
    <html>
    <head>
      not valid html code
      <meta..../>
    PHP:
    Regards, Denis
     
    INTEMPO, Jan 2, 2007 IP
  4. LazyD

    LazyD Peon

    Messages:
    425
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here is my code...

    Also something to note that when you go to the page the title and meta tags show up correctly when Viewing Source

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    		<html>
    			<head>
    <?php include("Admin/config.php");
    include("Admin/Ads/randad.php");
    $CategoryGet=$_GET['Category'];
    $SubCategoryGet=$_GET['SubCat'];
    $CardIDGet=$_GET['CardID'];
    $CardNameGet=$_GET['CardName'];
    
    switch ($CategoryGet){
    	case "bad":
    	If (isset($SubCategoryGet)) {
    		switch ($SubCategoryGet) {
    			case "bad":
    			$PageTitle = "getCredit365.Com | Credit Cards for Bad Credit";
    			$Headline = "Credit Cards for Bad Credit";
    			$query = "SELECT * FROM Cards WHERE Category='Poor Credit'";
    			$Keywords = "bad credit card, credit cards for bad credit, poor credit, no credit, damaged credit, instant bad credit, bad credit visa, bad credit mastercard";
    			break;
    			case "prepaid":
    			$PageTitle = "getCredit365.Com | Pre-Paid/Debit Cards";
    			$Headline = "Pre-Paid/Debit Cards";
    			$query = "SELECT * FROM Cards WHERE Category='Pre-Paid'";
    			$Keywords = "pre paid credit card, pre paid card, debit card, secured credit card, secured card bad credit, secured bad credit, pre paid debit card, pre paid visa, pre paid mastercard";
    			break;
    			case "catalog":
    			$PageTitle = "getCredit365.Com | Catalog Credit Cards";
    			$Headline = "Catalog Credit Cards";
    			$query = "SELECT * FROM Cards WHERE Category='Catalog'";
    			$Keywords = "catalog credit card, catalog card, bad catalog credit, USA catalog";
    			break;
    		}
    		} Else {
    			$PageTitle = "getCredit365.Com | All Cards for Bad Credit";
    			$Headline = "All Cards for Bad Credit";
    			$query = "SELECT * FROM Cards WHERE Category='Poor Credit' OR Category='Pre-Paid' OR Category='Catalog'";
    			$Keywords = "bad credit card, secured card, pre paid credit card, catalog credit, no credit credit card, poor credit credit card";
    		}
    		break;
    		case "good":
    		$PageTitle = "getCredit365.Com | Credit Cards for Good Credit";
    		$Headline = "Credit Cards for Good Credit";
    		$query = "SELECT * FROM Cards WHERE Category='Regular' OR Category='Charge'";
    		$Keywords = "credit card, good credit credit card, excellent credit credit card, visa card, mastercard, visa credit card, mastercard credit card, amex, american express card";
    		break;
    		case "rewards":
    		If (isset($SubCategoryGet)) {
    			switch ($SubCategoryGet) {
    				case "airline":
    				$PageTitle = "getCredit365.Com | Airline Rewards Credit Cards";
    				$Headline = "Airline Rewards Credit Cards";
    				$query = "SELECT * FROM Cards WHERE Category='Reward - Airline'";
    				$Keywords = "airline rewards credit card, united rewards credit card, southwest rewards, american airlines rewards credit card, air credit card";
    				break;
    				case "auto":
    				$PageTitle = "getCredit365.Com | Auto/Gas Rewards Credit Cards";
    				$Headline = "Auto/Gas Rewards Credit Cards";
    				$query = "SELECT * FROM Cards WHERE Category='Reward - Auto' OR Category='Reward - Gas'";
    				$Keywords = "auto rewards credit card, car rewards credit card, gas rewards, gasoline rewards, gas credit card";
    				break;
    				case "cash":
    				$PageTitle = "getCredit365.Com | Cash/Retail Rewards Credit Cards";
    				$Headline = "Cash/Retail Rewards Credit Cards";
    				$query = "SELECT * FROM Cards WHERE Category='Reward - Cash' OR Category='Reward - Other' OR Category='Reward - Retail' ";
    				$Keywords = "cash rewards credit card, retail rewards credit card, cash back credit card, cash rewards, retail rewards, overstock rewards, ebay rewards, amazon rewards";
    				break;
    				case "travel":
    				$PageTitle = "getCredit365.Com | Travel Rewards Credit Cards";
    				$Headline = "Travel/Hotel Rewards Credit Cards";
    				$query = "SELECT * FROM Cards WHERE Category='Reward - Travel' OR Category='Reward - Hotel'";
    				$Keywords = "travel rewards credit card, hotel rewards credit card, travel rewards, hotel rewards, hilton rewards card, starwood rewards, travel credit card, hotel credit card";
    				break;
    			}
    			} Else {
    				$PageTitle = "getCredit365.Com | All Rewards Credit Cards";
    				$Headline = "All Rewards Credit Cards";
    				$query = "SELECT * FROM Cards WHERE Category='Reward - Cash' OR Category='Reward - Auto' OR Category='Reward - Travel' OR Category='Reward - Gas' OR Category='Reward - Hotel' OR Category='Reward - Airline' OR Category='Reward - Retail' OR Category='Reward - Other'";
    				$Keywords = "rewards credit cards, visa rewards credit, mastercard rewards credit, travel rewards credit card, cash back credit card, reward credit card, points credit card";
    			}
    			break;
    			case "student":
    			$PageTitle = "getCredit365.Com | Student Credit Cards";
    			$Headline = "Student Credit Cards";
    			$query = "SELECT * FROM Cards WHERE Category='Student'";
    			$Keywords = "student credit card, college credit card, student credit, college credit, student rewards credit card, no credit student credit";
    			break;
    			case "business":
    			$PageTitle = "getCredit365.Com | Business Credit Cards";
    			$Headline = "Business Credit Cards";
    			$query = "SELECT * FROM Cards WHERE Category='business' OR Category='Business'";
    			$Keywords = "business credit card, small business credit card, home business credit card, business credit, small business credit";
    			break;
    			default:
    			$PageTitle = "getCredit365.Com | Most Popular Credit Cards";
    			$Headline = "Most Popular Credit Cards";
    			$query = "SELECT * FROM Cards WHERE CardID=595 OR CardID=720 OR CardID=23 OR CardID=88 OR CardID=1033";
    			$Keywords = "popular credit cards, most popular credit cards, american express, visa, mastercard, discover, american express card, visa card";
    			break;
    		}
    ?>
    				<title><? echo $PageTitle ?></title>
    				<link rel="stylesheet" type="text/css" href="http://getcredit365.com/style.css"/>
    				<meta name="title" content="getCredit365.Com - <? echo $CategoryGet ?> Credit Cards" />
    				<meta http-equiv="Content-Type" content="text/html; windows-1252" />
    				<meta name="robots" content="index, follow" />
    				<meta name="description" content="We can help you find the perfect credit card, loan or insurance for any situation. Currently browsing - <? echo $Headline ?>" />
    				<meta name="keywords" content="<? echo $Keywords ?>" />
    				<meta name="MSSmartTagsPreventParsing" content="true" />
    				<META name="verify-v1" content="4/ak52G3czdnRnZJxDAs0/qc/137WLUAmqoQFEIfZyk=" />
    				<!--[if lte IE 6]>
    				<link rel="stylesheet" type="text/css" href="http://getcredit365.com/iehacks.css" />
    				<![endif]-->
    			</head>
    PHP:
     
    LazyD, Jan 2, 2007 IP