运行这段代码时存在一定问题,如图。
<?php//######################修改课题界面3########################## include "config.php"; include "admin_header.php";?> <title>修改课题</title><?php $query="update $jiaoshi_table set subject='$subject1' where id='$id'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query="update $jiaoshi_table set teacher='$teacher1' where id='$id'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query=mysql_query("update $jiaoshi_table set zhicheng='$zhicheng1' where id='$id'"); mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query=mysql_query("update $jiaoshi_table set specialized='$specialized1' where id='$id'"); mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query=mysql_query("update $jiaoshi_table set code='$select' where id='$id'"); mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query="update $jiaoshi_table set beizhu='$introduction' where id='$id'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $query="select number as sn,surplus as ssn from $jiaoshi_table where id='$id'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); $row=mysql_fetch_array($result); if($number1<$row[sn]) { if($number1<($row[sn]-$row[ssn])) { echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>人数不能少于现已选题人数,人数列修改失败!</big></b></font>"; echo"<meta http-equiv=\"refresh\" content=\"2;url=alter_keti.php\">"; exit; } else { $query2=mysql_query("update $jiaoshi_table set number='$number1' where id='$id'"); $query3=mysql_query("update $jiaoshi_table set surplus=surplus-($row[sn]-$number1) where id='$id'"); mysql_query("set names 'GB2312'"); $result1=mysql_query($query3); } } else { $query4=mysql_query("update $jiaoshi_table set number='$number1' where id='$id'"); $query5=mysql_query("update $jiaoshi_table set surplus=surplus+($number1-$row[sn]) where id='$id'"); mysql_query("set names 'GB2312'"); $result2=mysql_query($query5); } if($result==true) { echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>修改课题成功!</big></b></font>"; echo "<meta http-equiv=\"refresh\" content=\"1;url=alter_keti.php\">"; exit; } else { echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>修改出错,请返回重新修改</big></b></font></p>"; echo "<meta http-equiv=\"refresh\" content=\"1;url=alter_keti.php\">"; exit; } ?><?php include "foot.php";?>
部分功能简介:商品收藏夹功能热门商品最新商品分级价格功能自选风格打印结算页面内部短信箱商品评论增加上一商品,下一商品功能增强商家提示功能友情链接用户在线统计用户来访统计用户来访信息用户积分功能广告设置用户组分类邮件系统后台实现更新用户数据系统图片设置模板管理CSS风格管理申诉内容过滤功能用户注册过滤特征字符IP库管理及来访限制及管理压缩,恢复,备份数据库功能上传文件管理商品类别管理商品添加/修改/
0
全部是一些没有定义的变量$subject1、$id、$teacher1...
另外,同一条件的update 语句可以写在一起。执行一次就够了。
全部是一些没有定义的变量$subject1、$id、$teacher1...
另外,同一条件的update 语句可以写在一起。执行一次就够了。
那我这样写对不对?
$query="update $jiaoshi_table set subject='$subject1',teacher='$teacher1',zhicheng='$zhicheng1',specialized='$specialized1' , code='$select',beizhu='$introduction'where id='$id'"; mysql_query("set names 'GB2312'"); $result=mysql_query($query); 上面的语句的对的
你的变量是通过表单提交过来的吧? 那就 $subject1=$_POST['subject1'] ;
extract($_REQUEST); //加上这句
$query="update $jiaoshi_table set subject='$subject1' where id='$id'";
....
extract($_REQUEST); //加上这句
$query="update $jiaoshi_table set subject='$subject1' where id='$id'";
.... 在哪个位置定义变量呢?
是这样定义的 $subject1=$_POST['subject1'] ; 吗?
你贴出的代码的第 7、8 行不是这样吗
$query="update $jiaoshi_table set subject='$subject1' where id='$id'";
把他改成这样
extract($_REQUEST); //加上这句
$query="update $jiaoshi_table set subject='$subject1' where id='$id'";
就可以了,其他都不要动
以后遇到类似的情况都这样做
Notice: Undefined variable: xxx
注意:未定义的变量: xxx
再新的手,也得会借助翻译看懂错误信息!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号