Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 36
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 37
[ убрать подсказку | никогда больше не показывать ]
Это предупреждение, вероятнее всего, возникает вследствие высокого уровня контроля ошибок в PHP, по умолчанию установленного в Денвере (E_ALL). Такой режим вывода ошибок является рекомендуемым и сильно помогает при отладке скриптов. Однако множество готовых скриптов требуют более низкого уровня ошибок.
Вы можете установить более слабый контроль ошибок одним из следующих способов:
Впишите в скрипты строчку:
Error_Reporting(E_ALL & ~E_NOTICE);
Этот способ особенно удобен, если в скрипте есть один файл (конфигурационный), который подключается всеми остальными.
Рекомендуемый способ. Создайте в директории со скриптом файл .htaccess следующего содержания:
php_value error_reporting 7
Исправьте в /usr/local/php/php.ini значение error_reporting на E_ALL & ~E_NOTICE. Этот способ не является рекомендуемым и может привести к серьезным неудобствам при отладке!
[Денвер: показать возможную причину ошибки]
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 48
Notice: Undefined variable: list in z:\home\test1.ru\www\guestbook.php on line 50
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 50
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 48
Warning: feof(): supplied argument is not a valid stream resource in z:\home\test1.ru\www\guestbook.php on line 48
Notice: Undefined variable: list in z:\home\test1.ru\www\guestbook.php on line 50
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 50
Warning: fgets(): supplied argument is not a valid stream resource in z:\home\test1.ru\www\guestbook.php on line 50
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 48
Warning: feof(): supplied argument is not a valid stream resource in z:\home\test1.ru\www\guestbook.php on line 48
Notice: Undefined variable: list in z:\home\test1.ru\www\guestbook.php on line 50
Notice: Undefined variable: file in z:\home\test1.ru\www\guestbook.php on line 50
вот такая вот фигня выскакивает на вот такой скрипт:
<html>
<head><meta http-equiv=Content-Type content="text/html; charset=windows-1251"></head>
<body background="pics/untitled.gif" bgcolor="black" bgproperties="fixed" style="color:white"
link="#404099" vlink="#4040ff" alink="#404099" >
<?
class message
{
var $name, $email, $org, $time, $text;
function message( $n, $em, $o, $tm, $txt )
{
$this->$name = $n;
$this->$email = $em;
$this->$org = $o;
$this->$time = tm;
$this->$text = $txt;
}
function print_message()
{
$n = $this->$name;
$o = $this->$org;
$em = $this->$email;
$tm = $this->$time;
$txt = $this->$text;
echo "<table width=600 align=center>", "<tr align=left>";
echo "<td><b>$n</b><br>$o<br>$em<br>$tm</td>";
echo "<td>$txt</td>", "</tr></table>";
}
}
class guestbook
{
var $file;
var $list;
var $messages;
function open4read()
{
$this->$file = fopen( "guestbook.dat", "rt" ) or die( "cant open file" );
flock( $this->$file, LOCK_SH );
}
function open4write()
{
$this->$file = fopen( "guestbook.dat", "a+t" ) or die( "cant open file" );
flock( $this->$file, LOCK_EX );
ftruncate( $this->$file, 0 );
}
function init_list()
{
$i = 0;
while( !feof( $this->$file ) )
{
$this->$list[$i] = fgets( $this->$file );
$i++;
}
}
function print_list()
{
$i = 0;
while( $i < count( $this->$list ) )
{
echo $this->$list[$i];
$i++;
}
}
function init_messages()
{
$i = 0;
$j = 0;
while( $i < count( $this->$list ) )
{
if( !strcmp( $this->$list[$i], "<!@#$%>\n" ) )
{
$name = $this->$list[++$i];
$org = $this->$list[++$i];
$email = $this->$list[++$i];
$time = $this->$list[++$i];
$text = "";
while( $this->$list[$i] != "</!@#$%>\n" )
{
$text .= $this->$list[$i];
}
$text = nl2br( $text );
$i++;
$this->$messages[$j++] = new message( $name, $org, $email, $time, $text );
}
}
}
function print_messages()
{
for( $i = 0; $i < count( $this->$messages ); $i++ )
{
$m = $this->messages[$i];
$m->print_messages();
echo "<br><hr>";
}
}
}
?>
<? if( !@$form )
{
$gb = new guestbook();
$gb->open4read();
$gb->init_list();
/*$gb->init_messages();
$gb->print_messages();
$gb->print_list();
fclose( $gb->$file );*/
?>
<form name="form" action="guestbook.php">
<table border="0" bordercolor="white" align="center">
<tr align="right">
<td bgcolor="#ff9900" style="color:black; right-margin:20pt">Имя:</td>
<td bgcolor="#ff9900"><input name="name" type="text" size="20"></td>
</tr>
<tr align="right">
<td bgcolor="#ff9900" style="color:black; right-margin:20pt">e-mail:</td>
<td bgcolor="#ff9900"><input name="mail" type="text" size="20"></td>
</tr>
<tr align="right">
<td bgcolor="#ff9900" style="color:black; right-margin:20pt">Организация:</td>
<td bgcolor="#ff9900"><input name="org" type="text" size="20"></td>
</tr>
</table><br>
<div align="center">
<textarea name="area" rows="10" cols="30"></textarea><br><br>
<input type="submit" value="написать">
</div>
</form>
<? } ?>
</body>
</html>
в чем дело помогите разобраться а то впервые столкнулся с пхп.
вероятно дело в классах?