Re: PHP function error

Поиск
Список
Период
Сортировка
От graeme
Тема Re: PHP function error
Дата
Msg-id 4225A2DB.2090509@sherubtse.edu.bt
обсуждение исходный текст
Ответ на PHP function error  ("Sarah, Godfrey, Matthew & Vera" <kyedza@sdf.lonestar.org>)
Список pgsql-php
Is dynamic.php in the same directory as index.php, switch your stetement
from include to require if it fails to find it them you'll learn where
it is looking for the file.

Just for future reference some servers require you php tags to be
written as <?php ... ?>

graeme.

Sarah, Godfrey, Matthew & Vera wrote:

> 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);
> }
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly
>
>

--
Experience is a good teacher, but she sends in terrific bills.

Minna Antrim



В списке pgsql-php по дате отправления:

Предыдущее
От: "Sarah, Godfrey, Matthew & Vera"
Дата:
Сообщение: PHP function error
Следующее
От: "Sarah, Godfrey, Matthew & Vera"
Дата:
Сообщение: Re: [**POSSIBLE SPAM**] PHP function error