解决方案 »

  1.   

    先查询一下  select accountid from .. where accountid=$accountid获者把这个字段设置成主键
      

  2.   

    将关于mysql函数 全部改成mssql前缀$sqlwhere = "select * from $dbzh where ……";//具体哪些字段重复,在where后面加上条件即可
    $result = mssql_query($sqlwhere);
    $num = mssql_num_rows($result); 
    if ($num  == 0){
        //新增操作
    }
      

  3.   

    根据你的,我修改了下,但是好像还是不行,数据插入不进去,提交注册信息后,数据库里没有。你帮我看看代码,是不是有问题。$ip = getip();
    $conn=mssql_connect('localhost','sa','aaaaaa') or die("SQL SERVER 数据库连接失败!");  //IP
    mssql_select_db('userdb',$conn);
    $sqlwhere = "select * from t_usercore where f_username !='$zhanghao'";//具体哪些字段重复,在where后面加上条件即可
     $result = mssql_query($sqlwhere);
     $num = mssql_num_rows($result); 
     if ($num  == 0){
     exit("<script type='text/javascript'>alert('注册失败,账号已存在!');location.href='register.php?id=$tgren'</script>");
         //新增操作
     } else{
     $sql="INSERT  INTO T_USERCORE( f_username, f_password, f_pwan, f_seconds, f_freeseconds, f_type ) VALUES  ( '$zhanghao', '$mima', '$email', 0 , 0 , 1 )";
    exit("<script type='text/javascript'>alert('$zhanghao 恭喜您注册成功!');location.href='login.php'</script>");
     }
    }
    exit("<script type='text/javascript'>alert('错误!');location.href='index.php'</script>");
      

  4.   

    你能解释一下 f_username !='$zhanghao' 的含义吗?
      

  5.   

    f_username !='$zhanghao' 
    f_username是MSSQL数据库中的字段,$zhanghao是注册页面表单提交的。。
      

  6.   

     我现在的问题就是,判断了以后,插入语句要怎么写,不会写啊。。我测试过,如果我不判断,直接用
     $sql="INSERT  INTO T_USERCORE( f_username, f_password, f_pwan, f_seconds, f_freeseconds, f_type ) VALUES  ( '$zhanghao', '$mima', '$email', 0 , 0 , 1 )";
    是可以成功提交数据的。。
      

  7.   

    <?php
    require 'account.php';
    //------UID的分配-------
    $uida = rand(10,999);
    $uidb = rand(2,99);
    function seed()
    {
    list($msec, $sec) = explode(' ', microtime());
    return (float) $sec;
    }
    srand(seed());
    $uidc =rand(1,99);
    $accountid = $uida.$uidb.$uidc;
    //------输出accountid-------
    //mysql_query("set names utf8");
    if(strlen($_GET['account']) > 0) {
    $zhanghao = $_GET['account'];
    $mima = md5($_GET['password']);
    $mimas = md5($_GET['passwords']);
    $email = $_GET['emai'];
    $tgren = $_GET['tgren'];
    if ($mima != $mimas){
    exit("<script type='text/javascript'>alert('两次输入的密码不一致');location.href='register.php?id=$tgren'</script>");
    }
    $ip = getip();
    $con = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("连接出错");//IP
    mysql_select_db($dbname,$con);
    mysql_query("set names 'latin1'");
    $time = date("Ymd");
    $sql = select count(account_id) from $dbzd where name = '$zhanghao';
    $sql_c = mysql_query($sql);
    if($sql_c){
    echo "用户名已经被占用,请更换用户名";
    }else{
    $sql="INSERT INTO $dbzh (account_id,name,phone,email,address,password,pointtime,netbar_ip) values ('$accountid','$zhanghao','$tgren','$email','$zsyb','$mima','$time','$ip')";
    exit("<script type='text/javascript'>alert('$zhanghao 恭喜您注册成功!');location.href='login.php'</script>");
    }

    if(mysql_query($sql,$con)==false){
      //$title ="Sorry"; //return 'no';
      exit("<script type='text/javascript'>alert('注册失败,账号已存在!');location.href='register.php?id=$tgren'</script>");
    }else{
      exit("<script type='text/javascript'>alert('$zhanghao 恭喜您注册成功!');location.href='login.php'</script>");
      //$title ="ok"; //return 'ok';
       
    }
    }
    exit("<script type='text/javascript'>alert('错误!');location.href='index.php'</script>");
    ?>
      

  8.   

    就是说你根本就不知道 f_username !='$zhanghao'  是什么意思了?
    这个表达式成立的条件是:只要字段 f_username 的内容与传入的数据 $zhanghao 不相等
    除非 f_username 的内容全部等于 $zhanghao ,否则条件一定成立
    也就是 $num = mssql_num_rows($result); 后,一定不等于 0
      

  9.   


    大神,我要插入的是MSSQL数据库.
    貌似用这个没用吧。。
      

  10.   

    不是帮不帮的问题,关键在于你是否知道你在做什么
    否则我也白说了,你也白问了f_username = '$zhanghao' 表示待检查的用户名是否已在表中
    如果在表中,那么 mssql_num_rows($result) 就不会等于 0
      

  11.   


    这个我当然知道啊,
    我自己根据大家的提示,调试了下,现在PHP提示注册成功,但是数据库里又没数据了,郁闷啊。。
     $conn=mssql_connect('192.168.1.103','sa','liu987112') or die("SQL SERVER 数据库连接失败!");  //IP
        mssql_select_db('userdb',$conn);
        $sql="INSERT INTO T_UserCore( F_UserName, F_PassWord, F_PWAN, F_Seconds, F_FreeSeconds, F_Type ) VALUES  ( '$zhanghao', '$mima', '$email', 0 , 0 , 1 )";
    我直接这样插入数据,都保存不到,不知道神马问题。。
      

  12.   

    当然知道还写出错误的逻辑?你知道 mssql_get_last_message 函数是做什么用的吗?