$querySql="select * from 119_wjqs where contentid='$contentid'";
$ts=mysql_query($querySql,$link) ; if($reccount <>0){
$sql="UPDATE `119`.`119_wjqs` SET `dw1` = '司令部',`qstime` = '$qstime1' ,`username1` = '$username' WHERE `119_wjqs`.`contentid` = `$contentid` LIMIT 1 ";
echo"<Script>window.location.href='wjqs.php?contentid=$contentid';</Script>";
}
else
{
$sql="INSERT INTO 119_wjqs (contentid,dw1,username1,qstime1) VALUES ('$contentid','司令部','$username','$qstime')";
echo"<Script>window.location.href='wjqs.php?contentid=$contentid';</Script>";
}
break; 我是php初学者,请教一下,我想判断一下数据库里是否有一条记录,如果有,那么则更新,如果没有,那么则添加.
$ts=mysql_query($querySql,$link) ; if($reccount <>0){
$sql="UPDATE `119`.`119_wjqs` SET `dw1` = '司令部',`qstime` = '$qstime1' ,`username1` = '$username' WHERE `119_wjqs`.`contentid` = `$contentid` LIMIT 1 ";
echo"<Script>window.location.href='wjqs.php?contentid=$contentid';</Script>";
}
else
{
$sql="INSERT INTO 119_wjqs (contentid,dw1,username1,qstime1) VALUES ('$contentid','司令部','$username','$qstime')";
echo"<Script>window.location.href='wjqs.php?contentid=$contentid';</Script>";
}
break; 我是php初学者,请教一下,我想判断一下数据库里是否有一条记录,如果有,那么则更新,如果没有,那么则添加.
解决方案 »
- PHP调用WebService,但是有一个windows平台的验证,我怎么样可以不用登陆,直接通过验证?
- PHP面试题
- 一个很菜的问题
- 用php在apache中执行系统命令时,系统是以什么用户去执行的?
- 关于SECLET语句的一些问题,希望高手解救,谢谢!
- textarea中文字直接保存到MYSQL中再读出显示,内容中的换行消失了!
- 请问在php里如何操作ini文件
- 我在一个字段中存入一图片的路径(客户端),然后打开...服务端运行无误,但在客户端运行出错。
- 为什么会出现这样的错误?
- php的基础问题.问几个关于php的网站地址。
- php socket问题
- 一些大型网站是怎么把.php文件显示成.html文件的
$ts=mysql_query($querySql,$link) ;
$reccount=mysql_num_rows($ts);//加多這行
if($reccount <>0){
$sql="UPDATE `119`.`119_wjqs` SET `dw1` = '司令部',`qstime` = '$qstime1' ,`username1` = '$username' WHERE `119_wjqs`.`contentid` = `$contentid` LIMIT 1 ";
mysql_query($Sql,$link) ;
echo" <Script>window.location.href='wjqs.php?contentid=$contentid'; </Script>";
}
else
{
$sql="INSERT INTO 119_wjqs (contentid,dw1,username1,qstime1) VALUES ('$contentid','司令部','$username','$qstime')";
mysql_query($Sql,$link) ;
echo" <Script>window.location.href='wjqs.php?contentid=$contentid'; </Script>";
}
break;
mysql_query($Sql,$link) ;
$ts=mysql_query($querySql,$link) ;
$reccount=mysql_num_rows($ts);//加多這行
if($reccount <>0){
$sql="UPDATE `119`.`119_wjqs` SET `dw1` = '司令部',`qstime` = '$qstime1' ,`username1` = '$username' WHERE `119_wjqs`.`contentid` = `$contentid` LIMIT 1 ";
mysql_query($Sql,$link) or die(mysql_eror().$sql) ;
echo" <Script>window.location.href='wjqs.php?contentid=$contentid'; </Script>";
}
else
{
$sql="INSERT INTO 119_wjqs (contentid,dw1,username1,qstime1) VALUES ('$contentid','司令部','$username','$qstime')";
mysql_query($Sql,$link) or die(mysql_eror().$sql) ;
echo" <Script>window.location.href='wjqs.php?contentid=$contentid'; </Script>";
}
break; 加or die(mysql_eror().$sql) ; 看哪個位置出錯了,再修改你的SQL語句