0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
阅读:2358回复:26

[求助]php总是显示notice怎么去掉?

楼主#
更多 发布于:2004-07-14 12:02
rt
如:
Notice: Undefined variable: page in ********\shop\guestbook.php on line 20

改了php.ini如下:

; Examples:
;
;   - Show all errors, except for notices
;
error_reporting = E_ALL & ~E_NOTICE
;
;   - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
;   - Show all errors except for notices
;
;error_reporting  = E_ALL; display all errors, warnings and notices

-------------------- [em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/go2west/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
1C#
发布于:2004-07-19 21:44
Re:[求助]php总是显示notice怎么去掉?
整个改了一下,现在的简洁明了,也没有什么notice了,哈哈.....................
还是我自己的问题 -------------------- [em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/akayi/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
2C#
发布于:2004-07-19 12:13
Re:[求助]php总是显示notice怎么去掉?
哦,这个now()不是php的now(),是sql的now();

我在外面访问不了……
嘿嘿 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
3C#
发布于:2004-07-19 12:10
Re:[求助]php总是显示notice怎么去掉?
我觉得也不是代码的原因。
不过我看到那个sql语句好像有点问题。
php 没有 now()函数吧,是asp 里面的。
php里的时间函数是  time,不过用的最多的是date()格式化输出时间。
比如:  date("Y-n-j h:i:s")
y  年..

但是now()也能用,我也不知道
http://10.64.7.108/shop/addnote.php
这也是一个测试服务器,是LINUX的,不会产生notice
但是添加到数据库的代码不能运行,用http://10.64.7.108/shop/guestbook.php查看会发现数据没有添加成功
刚刚才发现用这台服务器时分页也不起作用
--------------------
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/akayi/]感情欠费中
           爱情停机中
                       工作寻找中[/a]

[ 2004-07-19 12:13:00 0000 修改 ] [ 2004-07-19 12:14:21 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
4C#
发布于:2004-07-19 12:05
Re:[求助]php总是显示notice怎么去掉?
我觉得也不是代码的原因。
不过我看到那个sql语句好像有点问题。
php 没有 now()函数吧,是asp 里面的。
php里的时间函数是  time,不过用的最多的是date()格式化输出时间。
比如:  date("Y-n-j h:i:s")
y  年
n  月
j  日
h  时(24小时制)
i  分
s  秒
l  星期几的英文全名
d  本月的第几日
F  月份的英文全名
-------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
5C#
发布于:2004-07-19 11:59
Re:[求助]php总是显示notice怎么去掉?
肯定是没问题了,但我觉得这一行还是会出现Notice,会说addaction没有定义(现在不是用的我的机器,没法测试,下午去机房才能测试)
<?php
if($addaction!=1):
//user should input data at first;
?>

不像是代码编写的原因,应该是服务器的问题
非常感谢



--------------------
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/akayi/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
[ 2004-07-19 12:05:28 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
6C#
发布于:2004-07-19 11:55
Re:[求助]php总是显示notice怎么去掉?
我简化了你的代码:

test.php
<?php
if($addaction!=1):
//user should input data at first;
?>

<form action=test.php method=get>
<input type=text name="name">
<input type="hidden" name="addaction" value="1">
<input type=submit value=send>
</form>

<?php

else:
//if user had input data and send it ,then insert the date that user input into the

database;
$addaction=0;
echo $name;

endif;
?>

运行没有问题. -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
7C#
发布于:2004-07-19 11:48
Re:[求助]php总是显示notice怎么去掉?

上面的程序没看出有什么错误,还有也灭有看见  $addaction变量有什么作用。还有就是这段代码的页面就是  addnote.php吧

这页就是addnote.php
addaction在表单中隐藏提交,用以决定是显示编辑用的表单还是进行数据处理
<input type="hidden" name="addaction" value="1">

addaction!=1显示编辑。。。。
addaction=1提交数据


--------------------
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/akayi/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
[ 2004-07-19 11:49:26 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
8C#
发布于:2004-07-19 11:41
Re:[求助]php总是显示notice怎么去掉?
我看程序结构是这样的
<?php
if($addaction!=1)
{
      留言;  //addnote.php负责添加数据
}
else
{
       $addaction=0;
       数据添加到数据库;
       打印“发表成功”;
       查看留言链接;
}
?>
后面部分好像没什么用。//form表单没有提交处理读项。


上面的程序没看出有什么错误,还有也灭有看见  $addaction变量有什么作用。还有就是这段代码的页面就是  addnote.php吧
我建议下次贴代码这样贴:
//
文件名

代码
//
比如上面你就可以这样:
addnote.php

<?php
……
?> -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
9C#
发布于:2004-07-19 11:39
Re:[求助]php总是显示notice怎么去掉?
源码很简单:

<?php
if($addaction != 1):
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<title>text</title>
</head>

<body class="body">
<form name="guestbook" method="post" action="addnote.php">
  name:    
  <input name="name" type="text" id="name">
  <br>
  email:
  <input name="email" type="text" id="email">
  <br>
  <textarea name="content" cols="80" rows="8"></textarea>
  <br>
  <input type="submit" name="Submit" value="提交">
  <input name="reset" type="reset" id="reset" value="重置">
  <input type="hidden" name="addaction" value="1">
</form>
</body>
</html>
<?php
else:
?>
<html>
<head>
<title>
add
</title>
</head>
<body>
<?php
$addaction = 0;
include ("conn.php");
//$sql="insert into mt_gb2 set Author='".$author."',Content='".$content."',Face='".$_POST['Face']."',Time=now(),IP='".$_SERVER['REMOTE_ADDR']."'";
$query = "INSERT INTO guestbook set username='".$name."',content='".$content."',gemail='".$email."',gdate=now()";
$result = mysql_query($query,$Mylink);
mysql_close($Mylink);
echo "note add success";
?>
<a href="guestbook.php">view</a>
</body>
</html>
<?php
endif;
?>

Notice: Undefined variable: addaction in d:\usr\www\html\shop\addnote.php on line 2


代码只有这些,其它的代码上面有说明,也修改不了了 -------------------- [em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/akayi/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
10C#
发布于:2004-07-19 11:31
Re:[求助]php总是显示notice怎么去掉?
怎么末尾有一段
<%
response.write "hello world"
%>

asp程序阿 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
11C#
发布于:2004-07-16 22:35
Re:[求助]php总是显示notice怎么去掉?
其它的代码是发现了这个论坛的一个漏洞测试时留下的,也删不掉了

还没弄明白漏洞的危害有多大,所以还没有通知ADMIN


--------------------
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/go2west/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
[ 2004-07-16 22:38:06 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
12C#
发布于:2004-07-16 22:34
Re:[求助]php总是显示notice怎么去掉?
功能很简单,添加留言


IF:
ELSE:
ENDIF;
是用来输出不同的页面
IF段输出编辑用的表单
ELSE段添加到数据库

功能可以实现,只是有那个NOTICE在页面上影响市容

--------------------
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/go2west/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
[ 2004-07-16 22:36:44 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
13C#
发布于:2004-07-16 21:00
Re:[求助]php总是显示notice怎么去掉?
今天我第一次见到
if;
else;
endif;

这种格式.我写php程序都是因循守旧
if()
{}
else if()
{}
else
{}

asp里是这种格式
if   ...   then
...
...
end if -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
14C#
发布于:2004-07-16 20:56
Re:[求助]php总是显示notice怎么去掉?
下周回公司测试一下.
这代码写的好乱啊,跟我以前一样.
我建议代码写的规范点,还有加上一些注释,主要介绍这段程序(或这个语句)的功能.
 调试主要通过  echo "hello";
-------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
15C#
发布于:2004-07-16 19:11
Re:[求助]php总是显示notice怎么去掉?
乱成一团了,表看表看[em100] -------------------- [em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/go2west/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
16C#
发布于:2004-07-16 18:36
Re:[求助]php总是显示notice怎么去掉?
[ 2004-07-20 09:33:49 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
17C#
发布于:2004-07-16 18:33
Re:[求助]php总是显示notice怎么去掉?
</textarea>
</form>

<%
response.write "hello world"
%> [ 2004-07-16 18:53:08 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
18C#
发布于:2004-07-16 18:15
Re:[求助]php总是显示notice怎么去掉?
<form name="test" method=post action="">
<textarea name="content" cols="80" rows="8"></textarea>
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
timeValue += ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</SCRIPT>
<form name=clock >
<input name=thetime style="font-size: 9pt;color:#000000;border:0" size=12>
<a href="#" onclick=javascript:startclock()>startclock</a>
</form>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hidden" value="1">
</form>
</body>
</html>
[ 2004-07-16 18:28:59 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
19C#
发布于:2004-07-16 18:11
Re:[求助]php总是显示notice怎么去掉?
源码很简单:

<?php
if($addaction != 1):
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<title>text</title>
</head>

<body class="body">
<form name="guestbook" method="post" action="addnote.php">
  name:  
  <input name="name" type="text" id="name">
  <br>
  email:
  <input name="email" type="text" id="email">
  <br>
  <textarea name="content" cols="80" rows="8"></textarea>
  <br>
  <input type="submit" name="Submit" value="提交">
  <input name="reset" type="reset" id="reset" value="重置">
  <input type="hidden" name="addaction" value="1">
</form>
</body>
</html>
<?php
else:
?>
<html>
<head>
<title>
add
</title>
</head>
<body>
<?php
$addaction = 0;
include ("conn.php");
//$sql="insert into mt_gb2 set Author='".$author."',Content='".$content."',Face='".$_POST['Face']."',Time=now(),IP='".$_SERVER['REMOTE_ADDR']."'";
$query = "INSERT INTO guestbook set username='".$name."',content='".$content."',gemail='".$email."',gdate=now()";
$result = mysql_query($query,$Mylink);
mysql_close($Mylink);
echo "note add success";
?>
 <a href="guestbook.php">view</a>
</body>
</html>
<?php
endif;
?>

Notice: Undefined variable: addaction in d:\usr\www\html\shop\addnote.php on line 2 [ 2004-07-16 18:14:56 0000 修改 ]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
0000
作家
作家
  • 铜币143枚
  • 威望34点
  • 贡献值1点
20C#
发布于:2004-07-16 18:08
Re:[求助]php总是显示notice怎么去掉?

我错了。
我没有遇见过,我没有发言权。
我想看看实际是怎么样的,我不喜欢抽象的东西。
我自以为还是php.ini的原因,如果两个版本的php.ini配置也一样的话,我就我也不知道怎么版,凉拌

-------------------..


态度太诚恳了[em071] -------------------- [em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]
[em074]趴在楼下的背上睡得呼呼的Zzzzzz............[em074]
[em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074][em074]

[a=http://home.itdrp.com/go2west/]感情欠费中
           爱情停机中
                       工作寻找中[/a]
.--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
21C#
发布于:2004-07-16 16:19
Re:[求助]php总是显示notice怎么去掉?
把程序贴出来,我来看看。

这两天正在写php程序,做一个论坛,我就照wait4c的格式做的,做了两天了,在有一天基本上就可以完成了。 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
22C#
发布于:2004-07-16 16:17
Re:[求助]php总是显示notice怎么去掉?
不会
都是 php4.3.*


--------------------
[email protected]

我错了。
我没有遇见过,我没有发言权。
我想看看实际是怎么样的,我不喜欢抽象的东西。
我自以为还是php.ini的原因,如果两个版本的php.ini配置也一样的话,我就我也不知道怎么版,凉拌 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
slw4qd
著名写手
著名写手
  • 铜币2枚
  • 威望0点
  • 贡献值0点
23C#
发布于:2004-07-16 14:39
Re:[求助]php总是显示notice怎么去掉?
不会
都是 php4.3.*
-------------------- [email protected]
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
24C#
发布于:2004-07-15 13:02
Re:[求助]php总是显示notice怎么去掉?
那是因为php版本的问题。

你在win下用的可能是php4,在linux下用的可能是php3(系统带的),我的就是这种情况。如果熟悉的话,可以修改php.ini文件 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
slw4qd
著名写手
著名写手
  • 铜币2枚
  • 威望0点
  • 贡献值0点
25C#
发布于:2004-07-15 10:21
Re:[求助]php总是显示notice怎么去掉?
但是 同样的程序 放在linux下没有提示 -------------------- [email protected]
southeast
著名写手
著名写手
  • 铜币0枚
  • 威望0点
  • 贡献值0点
26C#
发布于:2004-07-14 12:56
Re:[求助]php总是显示notice怎么去掉?
我到没遇见过这种问题,前面加@就可以屏蔽错误 -------------------- 好好吃饭,天天睡觉
努力赚钱,娶个老婆
[img]http://www.wait4c.com/bbs/userfiles/2196/2005051614543457820.jpg[/img]
游客

返回顶部