错误提示是什么呀?
你说的这种情况还是第一次遇见.你的insert语句中是否包含别的数据库操作的?
比如通过查询记录+1来确定此次插入记录的ID什么的.

解决方案 »

  1.   

    function save_ip($ipadd){
    $ip=$ipadd;
    $t=getdate();
    $db=mysql_connect($serverhost,$loginmysqluser,$loginmysqlpassword);
    mysql_select_db("datasql",$db);
    $sql ="select * from ipaddress";
    $row=mysql_query($sql,$db);
    while($r=mysql_fetch_array($row)){
    if($r["ipdizhi"]!=$ip)
        {$nottrue="on";}
      else{$nottrue="off";}
      echo $nottrue;}
    echo $nottrue;
    if ($nottrue=="on"){
    $sql1="INSERT INTO ipaddress ( ipdizhi , shijian ) VALUES ( '$ip' , '".$_SESSION['now']."' )";
    $query1=mysql_query($sql1,$db);
    mysql_close($db);}}
      

  2.   

    $row=mysql_query($sql,$db);
    while($r=mysql_fetch_array($row)){
    if($r["ipdizhi"]!=$ip)
        {$nottrue="on";}
      else{$nottrue="off";}
      echo $nottrue;}修改为:if($row = mysql_query($sql, $db)) { //这里加一个判断,如果有记录得话,执行下面得
      while($r = mysql_fetch_array($row)) {
    if($r["ipdizhi"] != $ip) {
                 $nottrue = "on";
             } else {
                 $nottrue = "off";
             }
      }
    } else { //没有任何记录得话
        $nottrue = "on";
    }
      echo $nottrue;另外给你得建议是:希望你得编码写得规范一点!