php添加更新数据哪里错了
session_start();header("Content-Type:text/html;charset=utf-8");include("Conn/conn.php...
session_start();
header("Content-Type:text/html;charset=utf-8");
include("Conn/conn.php");
//$username=$_SESSION["username"];
$ggbjmid=$_POST['ggbjmid'];//隐藏域id
$gonggao=trim($_POST['gonggao']);
date_default_timezone_set("PRC"); // 获取系统时间更新数据库
$addtime=date("Y-m-j H:i:s");
$query = mysql_query("select * from tb_shop_xinxi where mid='$ggbjmid'"); //查询数据库
if($value = mysql_fetch_array($query)){
mysql_query("update tb_shop_xinxi set GongGao ='$gonggao', GongGaoAddTime='$addtime' where mid = '$ggbjmid' ");//如果有数据
}else{
mysql_query("insert into tb_shop_xinxi(mid,GongGao,GongGaoAddTime) values('$ggbjmid','$gonggao','$addtime')");//如果无数据,插入一条数据
if($query){
echo "<script language='javascript'>alert('信息修改成功!');history.back();</script>";}else{echo "<script language='javascript'>alert('修改失败!');history.back();</script>";} 展开
header("Content-Type:text/html;charset=utf-8");
include("Conn/conn.php");
//$username=$_SESSION["username"];
$ggbjmid=$_POST['ggbjmid'];//隐藏域id
$gonggao=trim($_POST['gonggao']);
date_default_timezone_set("PRC"); // 获取系统时间更新数据库
$addtime=date("Y-m-j H:i:s");
$query = mysql_query("select * from tb_shop_xinxi where mid='$ggbjmid'"); //查询数据库
if($value = mysql_fetch_array($query)){
mysql_query("update tb_shop_xinxi set GongGao ='$gonggao', GongGaoAddTime='$addtime' where mid = '$ggbjmid' ");//如果有数据
}else{
mysql_query("insert into tb_shop_xinxi(mid,GongGao,GongGaoAddTime) values('$ggbjmid','$gonggao','$addtime')");//如果无数据,插入一条数据
if($query){
echo "<script language='javascript'>alert('信息修改成功!');history.back();</script>";}else{echo "<script language='javascript'>alert('修改失败!');history.back();</script>";} 展开
展开全部
<?php
session_start();
header('Content_Type:text/html;charset=utf-8');
date_default_timezone_set('PRC');
include_once 'Conn/conn.php';
$ggbjmid = $_POST['gonggao'];
$gonggao = trim($_POST['gonggao']);
$addtime = date('Y-m-d H:i:s');
$query = mysql_query('select `mid` from `tb_shop_xinxi` where `mid` = \'' . $ggbjmid . '\'');
$Sql = mysql_num_rows( $query ) ? 'update `tb_shop_xinxi` set `GongGao` = \'' . $gonggao . '\', GongGaoAddTime = \'' . $addtime.'\' where `mid` = \'' . $ggbjmid. '\'' : 'insert into `tb_shop_xinxi`(`mid`, `GongGao`, `GongGaoAddTime`) values (\'' . $ggbjmid . '\', \'' . $gonggao . '\', \'' . $addtime . '\')';
$Msg = mysql_query( $Sql ) ? '信息修改成功' : '修改失败';
echo '
<script type="text/javascript">
<!--
alert("' . $Msg . '");
history.back();
//-->
';
die('</script>');
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询