...

View Full Version : noob needs help



landguy
08-31-2009, 03:19 PM
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];


}

}



?>

_Aerospace_Eng_
08-31-2009, 03:26 PM
Change this

$database = 'meta_tags.txt';
to this

$database = $_SERVER['DOCUMENT_ROOT'].'/meta_tags.txt';

landguy
08-31-2009, 03:31 PM
awesome thanks

landguy
09-01-2009, 02:45 PM
That doesn't seem to work any other suggestions?

_Aerospace_Eng_
09-01-2009, 02:55 PM
It should work unless you are doing something wrong. Change this

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

<?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.

landguy
09-01-2009, 03:07 PM
<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 />
">

_Aerospace_Eng_
09-01-2009, 03:11 PM
In get_meta.php change this

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

{

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

{

$title = $data[1];

$meta_description = $data[2];

$meta_keywords = $data[3];


}

}
to this


$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];


}

}

landguy
09-01-2009, 03:20 PM
comes up blank

<title></title>

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

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

landguy
09-01-2009, 03:21 PM
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
09-01-2009, 03:25 PM
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

_Aerospace_Eng_
09-01-2009, 03:56 PM
Is get_meta.php in the directory folder or is in the root of your site?

landguy
09-01-2009, 04:08 PM
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/26/d283681122/htdocs/site.com/page.php

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

_Aerospace_Eng_
09-01-2009, 04:12 PM
Change this

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

<?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.

landguy
09-01-2009, 04:12 PM
I saw that same sort of line in the .htaccess? Thanks for your help on this

_Aerospace_Eng_
09-01-2009, 04:15 PM
Post your htaccess file.

landguy
09-01-2009, 04:20 PM
Options +Indexes
Satisfy any
Order Deny,Allow
Allow from 172.17.0.0/16
Allow from 212.227.35.64/27
Allow from 212.227.34.151
Allow from 212.227.34.190
Deny from all
RemoveType .html .gif
AuthType Basic
AuthName "Access for /logs"
AuthUserFile /kunden/homepages/26/d283681122/htpasswd
require user u53256614

landguy
09-01-2009, 04:24 PM
i was going to put this in there for google's pages that are already indexed

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [R=permanent,L]

but it wont let me upload it maybe have to change the permissions?

_Aerospace_Eng_
09-01-2009, 04:34 PM
Can you remove your htaccess file from the server and see if your code works? I don't see anything in there that should prevent your code from working though.

Also in the future "noob needs help" isn't a helpful thread title to anyone else. Obviously you need help, that's why you are here. Use a descriptive thread title in the future.

landguy
09-01-2009, 04:43 PM
can't remove it and can't change the permissions it's in a /logs folder

sorry for the title and thanks for your help again

It's very frustrating

_Aerospace_Eng_
09-01-2009, 04:46 PM
Well how did you add the htaccess file in the first place?

landguy
09-01-2009, 04:54 PM
it was already there in a /logs folder

i'm online with customer support right now

landguy
09-01-2009, 05:01 PM
is there any other was of doing what i want?

I would like to edit my meta tags from a separate file

they said i can put another one outside the /logs folder in the root?

_Aerospace_Eng_
09-01-2009, 05:55 PM
Yes by using what I've told you. There is nothing that stop that from working. Post all of your code as it is now.

landguy
09-01-2009, 09:03 PM
This is in the head in a page.php like this /directory/page.php


<?php include($_SERVER['DOCUMENT_ROOT'].'/get_meta.php'); ?>

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

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

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



get_meta is in the root directory


<?php


$database = $_SERVER['DOCUMENT_ROOT'].'/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];
}

}


?>



and meta_tags.txt is also in the root directory

format like this

page.php*name of page*description of site*keywords for page


Thanks

_Aerospace_Eng_
09-01-2009, 09:20 PM
Okay change this

<?php


$database = $_SERVER['DOCUMENT_ROOT'].'/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];
}

}


?>
to this

<?php
ini_set('display_errors','1');
error_reporting(E_ALL);

$database = $_SERVER['DOCUMENT_ROOT'].'/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];
}

}

echo 'Title: '.$title.'<br>';

echo 'Meta Description: '.$meta_description.'<br>';


echo 'Meta Keywords: '.$meta_keywords.'<br>';
?>
Now navigate directly to get_meta.php and post the output here.

landguy
09-01-2009, 09:26 PM
Notice: Undefined variable: title in /homepages/26/d283681122/htdocs/site.com/get_meta.php on line 34
Title:

Notice: Undefined variable: meta_description in /homepages/26/d283681122/htdocs/site.com/get_meta.php on line 36
Meta Description:

Notice: Undefined variable: meta_keywords in /homepages/26/d283681122/htdocs/site.com/get_meta.php on line 39
Meta Keywords:

_Aerospace_Eng_
09-01-2009, 09:45 PM
Okay what you have isn't what I gave you a while back. You need to declare $title, $meta_description, $meta_keywords before you can print them out in your main document.

landguy
09-01-2009, 09:48 PM
when i uploaded page.php , get_meta.php and meta_tags.txt to go-daddy a completely different server a box popped up


A username and password are being requested by http://www.site.com. The site says: "Access for /logs"

landguy
09-01-2009, 10:00 PM
Okay what you have isn't what I gave you a while back. You need to declare $title, $meta_description, $meta_keywords before you can print them out in your main document.



how will I do that?

landguy
09-01-2009, 10:01 PM
when i move page.php into the root directory it works

when i put it in a /directory/page.php it doesn't

landguy
09-01-2009, 10:20 PM
I tried like this also



<?php



$database = $_SERVER['DOCUMENT_ROOT'].'/meta_tags.txt';

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



$page = $_SERVER['SCRIPT_NAME'];

$page = substr($page, 1);





$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];


}

}



?>




when i move page.php out of the root directory it doesn't work but it works in the root directory


Thanks anyway

_Aerospace_Eng_
09-01-2009, 10:28 PM
Make a new file, doesn't matter what you call just make sure its a php file and put only this in there

<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
What is the result?

landguy
09-01-2009, 10:33 PM
/kunden/homepages/26/d283681122/htdocs/site.com

_Aerospace_Eng_
09-01-2009, 10:45 PM
Okay I see what is happening. You have this

$page = $_SERVER['SCRIPT_NAME'];

$page = substr($page, 1);
Once you put it in the directory, $page will now become something like directory/page.php and not page.php so to solve this change this

$page = $_SERVER['SCRIPT_NAME'];

$page = substr($page, 1);
to this

$page = basename($_SERVER['SCRIPT_NAME']);

landguy
09-01-2009, 11:27 PM
ah ahhhhhhhh yessss thanks so much for your time and effort

it works your the man!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum