pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sarah, Godfrey, Matthew & Vera <kyedza@sdf.lonestar.org>
To: pgsql-php@postgresql.org
Subject: PHP function error
Date: Wed, 02 Mar 2005 12:43:53 +0300
Message-ID: <6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org> (raw)
In-Reply-To: <422550A0.2040104@sherubtse.edu.bt>
References: <OF901127F6.9DA3944D-ON88256FB7.00761864-88256FB7.00767B34@sybex.com>
	<422550A0.2040104@sherubtse.edu.bt>

I am trying to run the following code but get the following error:

Fatal error: Call to undefined function show_title() in 
d:\webhost\build\index.php on line 13


This file is called "index.php"

<? include "dynamic.php"; ?>
<? if (empty($id)) $id = "Home"; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
         <title> <? show_title($id); ?> </title>
</head>
<body>
<? show_navigation($id); ?>
<? show_content($id); ?>
</body>
</html>

The other file "dynamic.php" has the following functions

/* dynamic.inc.php */


function show_title($id)
{
   $fp = fopen(get_filename($id), "r");
   if (!$fp) return;
   $line = trim(fgets($fp, 255));
   fclose($fp);
   echo $line;
}



function get_filename($id)
{
   $name = "file_$id.txt";
   if (file_exists($name))
   {
     return $name;
   } else {
     return "error.txt";
   }
}


function show_navigation($id)
{
   global $PHP_SELF, $SCRIPT_NAME;
   if (trim($PHP_SELF) == "") $PHP_SELF = $SCRIPT_NAME;
   $dir = opendir('.');
   if (!$dir) return;
   while ($file = readdir($dir))
   {
     if ( (ereg("^file_.*\.txt$", $file)) and (is_file($file)) )
     {
       $item = ereg_replace("^file_(.*)\.txt$", "\\1", $file);
       echo '<a href="'.$PHP_SELF.'?id='.urlencode($item).'">'.$item."</a>\n";
       if ($id == $item)
       {
         echo "<==";
       }
       echo "<br>\n";
     }
   }
}



function show_content($id)
{
   $fp = fopen(get_filename($id), "r");
   if (!$fp) return;
   $first = true;
   while (!feof($fp))
   {
     if ($fp)
     {
       $line = fgets($fp, 1024);
       if ($first)
       {
         $first = false;
       } else {
         echo $line;
       }
     }
   }
   fclose($fp);
} 





view thread (5+ messages)  latest in thread

Message-ID: <6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org>
Permalink:  ../6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org/
Also on:    postgresql.org/message-id/6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: kyedza@sdf.lonestar.org
  Subject: Re: PHP function error
  In-Reply-To: <6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org>
  References: <OF901127F6.9DA3944D-ON88256FB7.00761864-88256FB7.00767B34@sybex.com> <422550A0.2040104@sherubtse.edu.bt> <6.1.0.6.0.20050302123253.02422c88@mail.freeshell.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox