Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-31-2009, 02:19 PM   PM User | #1
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
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];


}

}



?>
landguy is offline   Reply With Quote
Old 08-31-2009, 02:26 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 08-31-2009, 02:31 PM   PM User | #3
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
awesome thanks
landguy is offline   Reply With Quote
Old 09-01-2009, 01:45 PM   PM User | #4
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
That doesn't seem to work any other suggestions?
landguy is offline   Reply With Quote
Old 09-01-2009, 01:55 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 09-01-2009, 02:07 PM   PM User | #6
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
<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 />
">
landguy is offline   Reply With Quote
Old 09-01-2009, 02:11 PM   PM User | #7
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 09-01-2009, 02:20 PM   PM User | #8
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
comes up blank

<title></title>

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

<meta name="keywords" content="">
landguy is offline   Reply With Quote
Old 09-01-2009, 02:21 PM   PM User | #9
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
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.
landguy is offline   Reply With Quote
Old 09-01-2009, 02:25 PM   PM User | #10
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
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
landguy is offline   Reply With Quote
Old 09-01-2009, 02:56 PM   PM User | #11
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 09-01-2009, 03:08 PM   PM User | #12
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
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
landguy is offline   Reply With Quote
Old 09-01-2009, 03:12 PM   PM User | #13
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 09-01-2009, 03:12 PM   PM User | #14
landguy
New Coder

 
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
landguy is an unknown quantity at this point
I saw that same sort of line in the .htaccess? Thanks for your help on this
landguy is offline   Reply With Quote
Old 09-01-2009, 03:15 PM   PM User | #15
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Post your htaccess file.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 PM.


Advertisement
Log in to turn off these ads.