Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 35

Thread: noob needs help

  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    noob needs help

    hi,

    I am new at this so be gentle.

    the script below works great if the web page is in the root directory

    but if its in a /directory/webpage.php structure, it will not put the meta tags in.

    I've tried ../meta_tags.txt and i can't seem to get it to work. It's gotta be simple I just can't get it.

    Thanks


    this is in the head tag

    <?php include('get_meta.php'); ?>

    <title><?php print $title; ?></title>

    <meta name="description" content="<?php print $meta_description; ?>">

    <meta name="keywords" content="<?php print $meta_keywords; ?>">





    this is the get_meta.php

    <?php



    $database = 'meta_tags.txt';

    $meta_db = fopen($database, 'r');



    $page = $_SERVER['SCRIPT_NAME'];

    $page = substr($page, 1);





    while($data = fgetcsv($meta_db, 9000, '*'))

    {

    if($data[0] == $page)

    {

    $title = $data[1];

    $meta_description = $data[2];

    $meta_keywords = $data[3];


    }

    }



    ?>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    $database 'meta_tags.txt'
    to this
    PHP Code:
    $database $_SERVER['DOCUMENT_ROOT'].'/meta_tags.txt'
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    awesome thanks

  • #4
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That doesn't seem to work any other suggestions?

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    It should work unless you are doing something wrong. Change this
    PHP Code:
    <?php include('get_meta.php'); ?>
    to this
    PHP Code:
    <?php
    ini_set
    ('display_errors','1');
    error_reporting(E_ALL);
    ?>
    <?php 
    include('get_meta.php'); ?>
    Tell use what error you get. You would be getting errors if you can't open the file.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <title><br />
    <b>Notice</b>: Undefined variable: title in <b>/homepages/26/d283681122/htdocs/site.com/destinations/page.php</b> on line <b>13</b><br />
    </title>

    <meta name="description" content="<br />
    <b>Notice</b>: Undefined variable: meta_description in <b>/homepages/26/d283681122/htdocs/site.com/destinations/page.php</b> on line <b>15</b><br />
    ">

    <meta name="keywords" content="<br />
    <b>Notice</b>: Undefined variable: meta_keywords in <b>/homepages/26/d283681122/htdocs/site.com/destinations/page.php</b> on line <b>17</b><br />
    ">

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    In get_meta.php change this
    PHP Code:
    while($data fgetcsv($meta_db9000'*'))

    {

    if(
    $data[0] == $page)

    {

    $title $data[1];

    $meta_description $data[2];

    $meta_keywords $data[3];


    }


    to this
    PHP Code:
    $title '';
    $meta_description '';
    $meta_keywords '';

    while(
    $data fgetcsv($meta_db9000'*'))

    {

    if(
    $data[0] == $page)

    {

    $title $data[1];

    $meta_description $data[2];

    $meta_keywords $data[3];


    }


    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    comes up blank

    <title></title>

    <meta name="description" content="">

    <meta name="keywords" content="">

  • #9
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It still works great if the web page is in the root directory even with the changes

    but if its in a /directory/webpage.php structure, it will not put the meta tags in.

  • #10
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've tried putting the files in the same directory arrrrghhhhhh

    this is in the head tag

    <?php
    ini_set('display_errors','1');
    error_reporting(E_ALL);
    ?>
    <?php include('get_meta.php'); ?>
    <title><?php print $title; ?></title>



    get_meta.php and meta_tags.txt are in the folder

    and in the main folder

  • #11
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Is get_meta.php in the directory folder or is in the root of your site?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #12
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i've tried both ways

    right now i have it in the directory

    what's wierd is i'm trying to do a 301 redirect test for 1 page not the one I have the code on and this comes up for the page in the address bar

    http://www.site.com/kunden/homepages...e.com/page.php

    which is sort of what the error message was, maybe has something to do with .htaccess

  • #13
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    PHP Code:
    <?php include('get_meta.php'); ?>
    to this
    PHP Code:
    <?php include($_SERVER['DOCUMENT_ROOT'].'/get_meta.php'); ?>
    Put get_meta.php in the root of your site. If that doesn't work then there is something else causing the problem.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #14
    New Coder
    Join Date
    Aug 2009
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I saw that same sort of line in the .htaccess? Thanks for your help on this

  • #15
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Post your htaccess file.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •