4 Pages V  1 2 3 > »   
Reply to this topicStart new topic
> Adding meta tags using Php

Solid Contributor

Group: Members
Joined: 30-September 03
Posts: 50
From: Murfreesboro, TN
post Nov 10 2003, 02:48 PM
I'm new to Php, how do I add meta tags to my code using php?
CODE


<meta name="description" CONTENT="">

<meta name="keywords" CONTENT=" ">

Offline Go to the top of the page

Star Member

Group Icon
Group: Hall Of Fame
Joined: 27-June 03
Posts: 2,104
From: Southampton, Hampshire, UK
post Nov 10 2003, 03:27 PM
Here is the PHP for the variables....
CODE


<?php

$tpTitle="Helping you to improve your web site";

$pgHeading="Site-Report.com - Helping you to improve your web site";

$pgDesc="Helping you to improve your web site";

$pgKeywords="site-report";

?>



... and here is the HTML for the head section...
CODE


<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>

<title><?php echo $tpTitle ?></title>

<meta name="description" content="<?php echo $pgDesc ?>"></meta>

<meta name="keywords" content="<?php echo $pgKeywords ?>"></meta>

</head>



Hope that helps,
Regards,
James
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 30-September 03
Posts: 50
From: Murfreesboro, TN
post Nov 10 2003, 04:10 PM
many thanks James
Offline Go to the top of the page

Star Member

Group Icon
Group: Hall Of Fame
Joined: 27-June 03
Posts: 2,104
From: Southampton, Hampshire, UK
post Nov 10 2003, 04:13 PM
Here to help! :-)
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 30-September 03
Posts: 50
From: Murfreesboro, TN
post Nov 10 2003, 04:26 PM
I tried it and keep getting below code:

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in

page_header.php on line 13

Any Idea?
Offline Go to the top of the page

Star Member

Group Icon
Group: Hall Of Fame
Joined: 27-June 03
Posts: 2,104
From: Southampton, Hampshire, UK
post Nov 10 2003, 04:29 PM
Can you post the code as you have it? The code I used works fine! wink.gif
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 30-September 03
Posts: 50
From: Murfreesboro, TN
post Nov 10 2003, 04:31 PM
$pgHeading="onlinemortgage101.com - Helping you to improve your web site";
$pgDesc="Helping millions Refinance home and get best mortgage loan rate quotes.";
$pgKeywords="Refinance Home, Mortgage Loan, Mortgage lead, Internet Mortgage Lead Talk";


<meta name="description" content="<?php echo $pgDesc ?>"></meta>
<meta name="keywords" content="<?php echo $pgKeywords ?>"></meta>
[/code]
Offline Go to the top of the page

Star Member

Group Icon
Group: Hall Of Fame
Joined: 27-June 03
Posts: 2,104
From: Southampton, Hampshire, UK
post Nov 10 2003, 04:40 PM
Missing bit shown in BOLD
<?php
$pgHeading="onlinemortgage101.com - Helping you to improve your web site";
$pgDesc="Helping millions Refinance home and get best mortgage loan rate quotes.";
$pgKeywords="Refinance Home, Mortgage Loan, Mortgage lead, Internet Mortgage Lead Talk";
?>

<meta name="description" content="<?php echo $pgDesc ?>"></meta>
<meta name="keywords" content="<?php echo $pgKeywords ?>"></meta>
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 30-September 03
Posts: 50
From: Murfreesboro, TN
post Nov 12 2003, 06:37 AM
thanks James..

get it
Offline Go to the top of the page

Technical Administrator

Group Icon
Group: Technical Administrators
Joined: 3-February 03
Posts: 3,926
From: Sydney Australia
post Nov 13 2003, 12:57 AM
BTW, don't have </meta> is my advice. Meta tags are unterminating, so <meta .... /> is better, or just >, not ></meta>.
Offline Go to the top of the page

Untested

Group: Members
Joined: 16-January 04
Posts: 1
From: West Virginia
post Jan 16 2004, 07:21 PM
I tried this and I had no errors, but the Meta Tag analyser on scrub the web couldn't find my tags. sad.gif
Offline Go to the top of the page

Star Member

Group Icon
Group: Hall Of Fame
Joined: 27-June 03
Posts: 2,104
From: Southampton, Hampshire, UK
post Jan 17 2004, 02:37 AM
Hi Cozone,

Post the generated HTML and we'll have a look for you.

Kind Regard,
James
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 17-December 03
Posts: 55
From: Pebble Beach, California
post Jan 26 2004, 01:27 AM
wouldnt it be easier and more bandwidth economical just to have the meta tags in html on the page?

ie:

QUOTE
echo \"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=\"._CHARSET.\"\">n\";
echo \"<META HTTP-EQUIV=\"EXPIRES\" CONTENT=\"0\">n\";
echo \"<META NAME=\"RESOURCE-TYPE\" CONTENT=\"DOCUMENT\">n\";
echo \"<META NAME=\"DISTRIBUTION\" CONTENT=\"GLOBAL\">n\";
echo \"<META NAME=\"AUTHOR\" CONTENT=\"$sitename\">n\";
echo \"<META NAME=\"COPYRIGHT\" CONTENT=\"Copyright © 2003 by $sitename\">n\";
echo \"<META NAME=\"KEYWORDS\" CONTENT=\" web design, webdesign, development, content management system, solution, ecommerce, commerce, ebusiness\">n\";
echo \"<META NAME=\"DESCRIPTION\" CONTENT=\"$slogan\">n\";
echo \"<META NAME=\"ROBOTS\" CONTENT=\"INDEX, FOLLOW\">n\";
echo \"<META NAME=\"REVISIT-AFTER\" CONTENT=\"1 DAYS\">n\";
echo \"<META NAME=\"RATING\" CONTENT=\"GENERAL\">n\";
Offline Go to the top of the page

Moderator

Group Icon
Group: Moderators
Joined: 29-August 02
Posts: 5,751
From: Bristol, UK
post Jan 26 2004, 04:11 AM
Not that you need all those META tags........
Offline Go to the top of the page

Moderator Alumni

Group Icon
Group: Hall Of Fame
Joined: 1-September 02
Posts: 9,213
From: UK
post Jan 26 2004, 10:34 AM
QUOTE(webmorpheus)
wouldnt it be easier and more bandwidth economical just to have the meta tags in html on the page?

Only if you had a unique page to place those tags in.

However, we are dynamically generating pages with PHP, so how would you have a unique meta description of each generated page? If you put a non-dynamic code into a dynamic template, it will be the same for all pages. That's fine for things that are supposed to be alike on all pages, but not for some meta tags.

Having the same description for each page is a beginners mistake. Beginners often think that the Meta description is to describe the website. It isn't. It is to describe each unique document.

Every page should have a unique and specific TITLE and a unique and specific DESCRIPTION.

There are just three Meta tags that are really worthwhile to include at all in any page:
Content type/charset
Description
Keywords

The rest are more harm than good.
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 17-December 03
Posts: 55
From: Pebble Beach, California
post Jan 26 2004, 05:07 PM
i stuctured one of my sites like this:

this is part of the header file that is included on all pages:

QUOTE

    echo \"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">n\";
    echo \"<html>n\";
    echo \"<head>n\";
    echo \"<title>$sitename - $page_name - $pagetitle</title>n\";

    include(\"includes/meta-$page_name.php\");


this is part of the actuall content pages:

QUOTE

$page_name = basename(dirname(__FILE__));
$pagetitle = \"- Content Page\";
$sitename = \"Booyaa.com\";

include(\"header.php\");


this gives each page its own unique meta include, looking at i dont know if one method is faster than the other, same amount of text either way, right?
Offline Go to the top of the page

Member

Group: Members
Joined: 13-August 03
Posts: 44
From: Chandigarh, India
post Jan 27 2004, 01:59 AM
Black_Knight already covered what I wanted to say. In today;s world, you need to optimize your website pages uniquely with different set of keywords related to your business so that you can have more and more top rankings and therefore traffic and sales.
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 17-December 03
Posts: 55
From: Pebble Beach, California
post Jan 27 2004, 05:00 PM
hey nakulgoyal,

i dont know if its creativity, but

http://www.cwsteam.com/

redifining

is the mispelling of:

redefining
Offline Go to the top of the page

Member

Group: Members
Joined: 13-August 03
Posts: 44
From: Chandigarh, India
post Jan 27 2004, 05:04 PM
I know. :-)
It's been ages since I updated this wbesite. No time for my own websites. :-(
Offline Go to the top of the page

Solid Contributor

Group: Members
Joined: 17-December 03
Posts: 55
From: Pebble Beach, California
post Jan 27 2004, 05:31 PM
thats good that you have no time, means you are making $$

how old are you, is that a business or are you an individual consultant?
Offline Go to the top of the page
Fast ReplyReply to this topic Start new topic
4 Pages V  1 2 3 > » 
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Jump to Forum:
 
Lo-Fi Version Time is now: 9th February 2010 - 03:15 PM
Meet our Moderators: cre8pc : projectphp : sanity : Black Phoenix : bwelford : EGOL : Ruud : rustybrick : AbleReach : swainzy : joedolson: eKstreme: dazzlindonna : SEOigloo: iamlost : RisaBB
Cre8asite RSS Feed