Notice: Undefined index: id in E:\wamp\wamp\www\liuyanbanban\modify.php on line 问题
来源:互联网 发布:java编程技术培训 编辑:程序博客网 时间:2024/04/29 21:03
以下是我在写modify.php时遇到的问题:
问题一:代码出现Notice: Undefined index: id in E:\wamp\wamp\www\liuyanbanban\modify.php on line这样的错误提示
解决方法:在两个if语句的判断语句里添加isset(),即形式为if(isset(判断语句))
这是因为在一开始还没收到submit,所以才会有这样的提示。
问题二:再修改之后,list网页中的信息不会修改
解决方法:由此可知,可能是sql语句出现了错误
我之前所写的错误的sql语句为: $sql="update message set title=$_POST[title',content=$_POST[content] where id=$_GET[id]";
正确的为: $sql="update message set title='$_POST[title]',content='$_POST[content]' where id=$_GET[id]";
即引号非常重要
我的代码:modify.php
<meta charset='UTF-8'>
<?php
//error_reporting(0);
include("conn.php");
if(isset($_POST['submit'])){
$sql="update message set title='$_POST[title]',content='$_POST[content]' where id=$_GET[id]";
mysql_query($sql);
echo "<script>alert('修改成功');location.href='list.php'</script>";
}
if(isset($_GET['id'])){
$sql="select * from message where id=$_GET[id]";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{
?>
<html>
<head>
<title>
新闻修改
</title>
<SCRIPT language=javascript>
function CheckPost()
{
if(myform.user.value=="")
{
alert("请填写用户名");
myform.user.focus();//光标聚焦
return false;
}
if(myform.title.value.length<5)
{
alert("标题不能少于5个字符");
myform.title.focus();
return false;
}
}
</SCRIPT>
</head>
<body>
<form action="" method="post" name="myform" onsubmit="return CheckPost()">
用户:<input type="text" name="user" value=<?php echo $row['user']?>><br>
标题:<input type="text" name="title" value=<?php echo $row['title']?>><br>
内容:<input type="text" name="content" value=<?php echo $row['content']?>><br>
<?php
}
?>
<input type="submit" name="submit" value="修改">
<?php
}
?>
</form>
</body>
</html>
- Notice: Undefined index: id in E:\wamp\wamp\www\liuyanbanban\modify.php on line 问题
- Undefined index: user in E:\wamp\wamp\www\liuyanbanban\login.php on line 4
- 如何解决 Notice: Undefined index: submit in D:\wamp\www\bbs\add.php on line 9
- 表单中PHP的错误提示:Notice: Undefined index: submit in D:\wamp\www\bbs\add.php on line 4
- Notice: Use of undefined constant title - assumed 'title' in D:\wamp\www\99Pursey\left.php on line
- 关于 Notice: Undefined index: 2 in C:\wamp\www\...报错
- 关于 Notice: Undefined index: 2 in C:\wamp\www\...报错
- Notice: Undefined index: submit in D:\.....php on line 2问题
- Notice: Undefined index: user in D:\phpStudy\WWW\js\ls\lsmc\php\add.php on line 9
- Notice: Constant CSS_URL already defined in C:\wamp\www\PHP\shop\index.php
- Fatal error: Call to a member function fetch_array() on a non-object in E:\wamp\www\shop\index.php
- Notice: Use of undefined constant mysql_fetch_array - assumed 'mysql_fetch_array' in E:\wamp\wamp\w
- 为什么会出现Notice: Undefined index: submit in D:\xampp\htdocs\test.php on line 19
- Notice: Undefined variable: data in /var/www/html/bbeden/modoer/ecshop/includes/lib_base.php on line
- 如何查找PHP中哪里符合配对有错?syntax error, unexpected $end in D:\wamp\www\index.php on
- PHP:Notice: Undefined index: submit in
- PHP Notice: Undefined index:
- PHP Notice: Undefined index: ... 问题的解决方案
- ISBN Sicily
- C++ 继承与多态
- 其它基本扩展->tidy,html美化与修复
- java执行方式 client/server
- 谷歌浏览器Adobe Flash player 已过期 解决办法
- Notice: Undefined index: id in E:\wamp\wamp\www\liuyanbanban\modify.php on line 问题
- (OK) 编译android6.0错误recipe for target 'out/host/linux-x86/obj/lib/libart.so' failed
- bzoj 3437: 小P的牧场
- linux下使用命令修改IP地址
- 密钥交换方法 在线可信任第三方、Merkle Puzzles及Diffie-Hellman原理简介
- 增值税专用发票图像识别技术
- 分布式事务处理 2pc 3pc
- Android中静态方式破解某App实现所有视频app去除广告功能
- linux下配置ip地址四种方法(图文方法)