Enjoy an ad free experience by logging in. Not a member yet?
Register .
08-31-2009, 02:19 PM
PM User |
#1
New Coder
Join Date: Aug 2009
Posts: 25
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];
}
}
?>
08-31-2009, 02:26 PM
PM User |
#2
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 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! ||||
08-31-2009, 02:31 PM
PM User |
#3
New Coder
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
awesome thanks
09-01-2009, 01:45 PM
PM User |
#4
New Coder
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
That doesn't seem to work any other suggestions?
09-01-2009, 01:55 PM
PM User |
#5
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 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! ||||
09-01-2009, 02:07 PM
PM User |
#6
New Coder
Join Date: Aug 2009
Posts: 25
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 />
">
09-01-2009, 02:11 PM
PM User |
#7
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
In get_meta.php change this
PHP Code:
while( $data = fgetcsv ( $meta_db , 9000 , '*' )) { 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_db , 9000 , '*' )) { 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! ||||
09-01-2009, 02:20 PM
PM User |
#8
New Coder
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
comes up blank
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
09-01-2009, 02:21 PM
PM User |
#9
New Coder
Join Date: Aug 2009
Posts: 25
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.
09-01-2009, 02:25 PM
PM User |
#10
New Coder
Join Date: Aug 2009
Posts: 25
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
09-01-2009, 02:56 PM
PM User |
#11
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 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! ||||
09-01-2009, 03:08 PM
PM User |
#12
New Coder
Join Date: Aug 2009
Posts: 25
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
09-01-2009, 03:12 PM
PM User |
#13
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 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! ||||
09-01-2009, 03:12 PM
PM User |
#14
New Coder
Join Date: Aug 2009
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
I saw that same sort of line in the .htaccess? Thanks for your help on this
09-01-2009, 03:15 PM
PM User |
#15
Supreme Master coder!
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
Post your htaccess file.
__________________
|||| If you are getting paid to do a job, don't ask for help on it! ||||
Jump To Top of Thread
Thread Tools
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
HTML code is Off
All times are GMT +1. The time now is 03:40 PM .
Advertisement
Log in to turn off these ads.