
Originally Posted by
cyjetsu
actually no thats not right, i have used it in the last line i added for testing. so there must be something wrong with the syntax of $logfile = $_SERVER['DOCUMENT_ROOT'] . '/' . $dir . '/logfile.txt'; only when on a live server?
Also strangly enough, $logfile = 'logfile.txt'; only works on localserver too.....
*edited*
I have now tried a few methods... it seems all of them work on localhost and all fail on my server... i suspect it has something to do with permissions on my webhost server now.
I have rightly or wrongly always used getcwd() to find out where the file is situated. I also have include a '_common.php' file that and this is one of the settings:
PHP Code:
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors','On');
define('LOCALHOST', 'localhost' === $_SERVER['SERVER_NAME']);
I would solve your problem with the different paths for the "logfile.txt" file like this.
PHP Code:
// default to Online
$logfile = $_SERVER['DOCUMENT_ROOT'] . '/' . $dir . '/logfile.txt';
if (LOCALHOST)
{
$logfile = getcwd() . '/logfile.txt';
}
if (!$handle = fopen($logfile, 'a+'))
{
die("Failed to open: " .$logfile);
}
As far as using a CMS and passing different $title parameters I use this code at the top of all files:
PHP Code:
<?php echo $doctype ?>
<head>
<?php echo $header ?>
</head>
and here is my header:
PHP Code:
<?php
// sometimes these variables are not set - easier to check here than to have an error
$keywords = isset($keywords) ? $keywords : 'Johns-Joke of the day';
$description = isset($description) ? $description : $keywords;
?>
<title>Johns Joke of the Day: <?= $joke_title ?></title>
<meta name="keywords" content="<?= $keywords ?>" />
<meta name="description" content="<?= $description ?>" />
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<link type="text/css" href="style_001.css" rel="stylesheet" />
<meta name="author" content="John_Betong" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="robots" content="follow, all" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<script type='text/css'>
<!--[if !IE]>-->
body {font-size:10px}
<!--<[endif]-->
</script>
As a matter of interest I use CodeIgniter an "Open Source Web Application Framework that helps you write kick-*** PHP programs". What application framework are you using?
Bookmarks