返回信息流比如 在文本域中输入012456789,提交后会将前面的0自动取消。
ps:并不是所有的都这样。
这是一条镜像帖。来源:北邮人论坛 / www-technology / #10634同步于 2010/8/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
求助大牛:php 表单数据提交到数据库中时 0 总是判断为空是怎么
bowinventer
2010/8/13镜像同步16 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
如果你对数据做了强制类型转换……
如果你的数据库字段定义为int而不是varchar或者text
如果你插入的时候没有使用引号引起来……
如果……
【 在 bowinventer (天地人神鬼) 的大作中提到: 】
: 比如 在文本域中输入012456789,提交后会将前面的0自动取消。
: ps:并不是所有的都这样。
代码就是普通的插入
if($_POST[action]=="modify"){
if(!($_POST[mobile] and $_POST[telphone] and $_POST[email] and $_POST[realname] and $_POST[address] and $_POST[postnum])) echo "输入不允许为空。点击<a href='javascript:onclick=history.go(-1)'>这里</a>返回";
else{
$sqlstr3 = "update preapply set mobile=".$_POST[mobile].",telphone = ".$_POST[telphone].", realname = '".$_POST[realname]."', email= '".$_POST[email]."',address = '".$_POST[address]."',postnum = ".$_POST[postnum].",subname = '".$_POST[subname]."',operator='$_SESSION[user]'where id = ".$_POST[id];
$result = mysql_query($sqlstr3,$conn);
if ($result){
echo "修改成功,点击<a href='confirm.php'>这里</a>查看";
}
else
echo "修改失败.<br>";
}
}
这个是数据更新的
if($_GET[action]=="modify"){
$sqlstr2="select* from preapply where id=$_GET[id]";
$result=mysql_query($sqlstr2,$conn) or die(mysql_error());
$rows = mysql_fetch_row($result);
?>
<form action="confirm.php" method="post">
手机:<input name="mobile" type="text" value="<?php echo $rows[1] ?>"/>
电话:<input name="telphone" type="text" value="<?php echo $rows[2] ?>"/>
email:<input name="email" type="text" value="<?php echo $rows[3] ?>"/>
真实姓名:<input name="realname" type="text" value="<?php echo $rows[4]?>"/>
联系地址:<input name="address" type="text" value="<?php echo $rows[5]?>"/>
邮编:<input name="postnum" type="text" value="<?php echo $rows[6]?>"/>
课程名称:<input name="subname" type="text" value="<?php echo $rows[8]?>"/>
<input type="hidden" name="action" value="modify">
<input type="hidden" name="id" value="<?php echo $rows[0] ?>">
<input name="Submit" type="submit" value="修改" />
<input type="reset" name="reset" value="重置">
</form>
<?
这个是表单的
如果是mobile、telphone、postnum、operator,那也许真的是引号的问题~~
【 在 bowinventer (天地人神鬼) 的大作中提到: 】
: 标 题: Re: 求助大牛:php 表单数据提交到数据库中时 0 总是判断为空是
: 发信站: 北邮人论坛 (Fri Aug 13 13:06:10 2010), 站内
:
: 代码就是普通的插入
: if($_POST[action]=="modify"){
: if(!($_POST[mobile] and $_POST[telphone] and $_POST[email] and $_POST[realname] and $_POST[address] and $_POST[postnum])) echo "输入不允许为空。点击<a href='javascript:onclick=history.go(-1)'>这里</a>返回";
: else{
: $sqlstr3 = "update preapply set mobile=".$_POST[mobile].",telphone = ".$_POST[telphone].", realname = '".$_POST[realname]."', email= '".$_POST[email]."',address = '".$_POST[address]."',postnum = ".$_POST[postnum].",subname = '".$_POST[subname]."',operator='$_SESSION[user]'where id = ".$_POST[id];
: $result = mysql_query($sqlstr3,$conn);
: if ($result){
: echo "修改成功,点击<a href='confirm.php'>这里</a>查看";
: }
: else
: echo "修改失败.<br>";
: }
: }
: 这个是数据更新的
: --
:
: ※ 来源:·北邮人论坛 http://bbs.byr.cn·[FROM: 219.224.99.*]